Chapter 2. API Reference
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] work: Pointer to the function to be executed in the HTTPD’s context
• [in] arg: Pointer to the arguments that should be passed to this function
void *httpd_sess_get_ctx(httpd_handle_t handle, int sockfd)
Get session context from socket descriptor.
Typically if a session context is created, it is available to URI handlers through the httpd_req_t structure.
But, there are cases where the web server’s send/receive functions may require the context (for example,
for accessing keying information etc). Since the send/receive function only have the socket descriptor at their
disposal, this API provides them with a way to retrieve the session context.
Return
• void* : Pointer to the context associated with this session
• NULL : Empty context / Invalid handle / Invalid socket fd
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] sockfd: The socket descriptor for which the context should be extracted.
void httpd_sess_set_ctx(httpd_handle_t handle, int sockfd, void *ctx, httpd_free_ctx_fn_t free_fn)
Set session context by socket descriptor.
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] sockfd: The socket descriptor for which the context should be extracted.
• [in] ctx: Context object to assign to the session
• [in] free_fn: Function that should be called to free the context
void *httpd_sess_get_transport_ctx(httpd_handle_t handle, int sockfd)
Get session ‘transport’context by socket descriptor.
This context is used by the send/receive functions, for example to manage SSL context.
See httpd_sess_get_ctx()
Return
• void* : Pointer to the transport context associated with this session
• NULL : Empty context / Invalid handle / Invalid socket fd
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] sockfd: The socket descriptor for which the context should be extracted.
void httpd_sess_set_transport_ctx(httpd_handle_t handle, int sockfd, void *ctx,
httpd_free_ctx_fn_t free_fn)
Set session ‘transport’context by socket descriptor.
See httpd_sess_set_ctx()
Parameters
• [in] handle: Handle to server returned by httpd_start
• [in] sockfd: The socket descriptor for which the context should be extracted.
• [in] ctx: Transport context object to assign to the session
• [in] free_fn: Function that should be called to free the transport context
void *httpd_get_global_user_ctx(httpd_handle_t handle)
Get HTTPD global user context (it was set in the server config struct)
Return global user context
Parameters
• [in] handle: Handle to server returned by httpd_start
void *httpd_get_global_transport_ctx(httpd_handle_t handle)
Get HTTPD global transport context (it was set in the server config struct)
Return global transport context
Parameters
Espressif Systems 585
Submit Document Feedback
Release v4.4