esp_http_server: Provide apps an option to let http_server ignore sess_ctx changes

By default, if a URI handler changes the http session context,
the webserver internally clears the older context after the handler
returns. However, if applications want to change this behavior and
manage the allocation/de-allocation/freeing themselves and let the
server handle only the "socket close" case, this commit provides such
an option.
This commit is contained in:
Piyush Shah
2019-03-05 00:21:03 +05:30
parent dace2d6bc5
commit f28f4016cb
3 changed files with 20 additions and 4 deletions

View File

@@ -362,6 +362,18 @@ typedef struct httpd_req {
* function for freeing the session context, please specify that here.
*/
httpd_free_ctx_fn_t free_ctx;
/**
* Flag indicating if Session Context changes should be ignored
*
* By default, if you change the sess_ctx in some URI handler, the http server
* will internally free the earlier context (if non NULL), after the URI handler
* returns. If you want to manage the allocation/reallocation/freeing of
* sess_ctx yourself, set this flag to true, so that the server will not
* perform any checks on it. The context will be cleared by the server
* (by calling free_ctx or free()) only if the socket gets closed.
*/
bool ignore_sess_ctx_changes;
} httpd_req_t;
/**