Struct esp_idf_sys::httpd_config

source ·
#[repr(C)]
pub struct httpd_config {
Show 25 fields pub task_priority: c_uint, pub stack_size: usize, pub core_id: BaseType_t, pub server_port: u16, pub ctrl_port: u16, pub max_open_sockets: u16, pub max_uri_handlers: u16, pub max_resp_headers: u16, pub backlog_conn: u16, pub lru_purge_enable: bool, pub recv_wait_timeout: u16, pub send_wait_timeout: u16, pub global_user_ctx: *mut c_void, pub global_user_ctx_free_fn: httpd_free_ctx_fn_t, pub global_transport_ctx: *mut c_void, pub global_transport_ctx_free_fn: httpd_free_ctx_fn_t, pub enable_so_linger: bool, pub linger_timeout: c_int, pub keep_alive_enable: bool, pub keep_alive_idle: c_int, pub keep_alive_interval: c_int, pub keep_alive_count: c_int, pub open_fn: httpd_open_func_t, pub close_fn: httpd_close_func_t, pub uri_match_fn: httpd_uri_match_func_t,
}
Expand description

@brief HTTP Server Configuration Structure

@note Use HTTPD_DEFAULT_CONFIG() to initialize the configuration to a default value and then modify only those fields that are specifically determined by the use case.

Fields§

§task_priority: c_uint

< Priority of FreeRTOS task which runs the server

§stack_size: usize

< The maximum stack size allowed for the server task

§core_id: BaseType_t

< The core the HTTP server task will run on

§server_port: u16

TCP Port number for receiving and transmitting HTTP traffic

§ctrl_port: u16

UDP Port number for asynchronously exchanging control signals between various components of the server

§max_open_sockets: u16

< Max number of sockets/clients connected at any time (3 sockets are reserved for internal working of the HTTP server)

§max_uri_handlers: u16

< Maximum allowed uri handlers

§max_resp_headers: u16

< Maximum allowed additional headers in HTTP response

§backlog_conn: u16

< Number of backlog connections

§lru_purge_enable: bool

< Purge “Least Recently Used” connection

§recv_wait_timeout: u16

< Timeout for recv function (in seconds)

§send_wait_timeout: u16

< Timeout for send function (in seconds)

§global_user_ctx: *mut c_void

Global user context.

This field can be used to store arbitrary user data within the server context. The value can be retrieved using the server handle, available e.g. in the httpd_req_t struct.

When shutting down, the server frees up the user context by calling free() on the global_user_ctx field. If you wish to use a custom function for freeing the global user context, please specify that here.

§global_user_ctx_free_fn: httpd_free_ctx_fn_t

Free function for global user context

§global_transport_ctx: *mut c_void

Global transport context.

Similar to global_user_ctx, but used for session encoding or encryption (e.g. to hold the SSL context). It will be freed using free(), unless global_transport_ctx_free_fn is specified.

§global_transport_ctx_free_fn: httpd_free_ctx_fn_t

Free function for global transport context

§enable_so_linger: bool

< bool to enable/disable linger

§linger_timeout: c_int

< linger timeout (in seconds)

§keep_alive_enable: bool

< Enable keep-alive timeout

§keep_alive_idle: c_int

< Keep-alive idle time. Default is 5 (second)

§keep_alive_interval: c_int

< Keep-alive interval time. Default is 5 (second)

§keep_alive_count: c_int

< Keep-alive packet retry send count. Default is 3 counts

§open_fn: httpd_open_func_t

Custom session opening callback.

Called on a new session socket just after accept(), but before reading any data.

This is an opportunity to set up e.g. SSL encryption using global_transport_ctx and the send/recv/pending session overrides.

If a context needs to be maintained between these functions, store it in the session using httpd_sess_set_transport_ctx() and retrieve it later with httpd_sess_get_transport_ctx()

Returning a value other than ESP_OK will immediately close the new socket.

§close_fn: httpd_close_func_t

Custom session closing callback.

Called when a session is deleted, before freeing user and transport contexts and before closing the socket. This is a place for custom de-init code common to all sockets.

The server will only close the socket if no custom session closing callback is set. If a custom callback is used, close(sockfd) should be called in here for most cases.

Set the user or transport context to NULL if it was freed here, so the server does not try to free it again.

This function is run for all terminated sessions, including sessions where the socket was closed by the network stack - that is, the file descriptor may not be valid anymore.

§uri_match_fn: httpd_uri_match_func_t

URI matcher function.

Called when searching for a matching URI: 1) whose request handler is to be executed right after an HTTP request is successfully parsed 2) in order to prevent duplication while registering a new URI handler using httpd_register_uri_handler()

Available options are: 1) NULL : Internally do basic matching using strncmp() 2) httpd_uri_match_wildcard() : URI wildcard matcher

Users can implement their own matching functions (See description of the httpd_uri_match_func_t function prototype)

Trait Implementations§

source§

impl Clone for httpd_config

source§

fn clone(&self) -> httpd_config

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for httpd_config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for httpd_config

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Copy for httpd_config

Auto Trait Implementations§

§

impl Freeze for httpd_config

§

impl RefUnwindSafe for httpd_config

§

impl !Send for httpd_config

§

impl !Sync for httpd_config

§

impl Unpin for httpd_config

§

impl UnwindSafe for httpd_config

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Copy,

§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.