|
GNU libmicrohttpd 1.0.5
|
Macros | |
| #define | _MHD_FIXED_ENUM |
Typedefs | |
| typedef void(* | MHD_RequestCompletedCallback) (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) |
| typedef void(* | MHD_NotifyConnectionCallback) (void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe) |
| typedef enum MHD_Result(* | MHD_KeyValueIterator) (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
| typedef enum MHD_Result(* | MHD_KeyValueIteratorN) (void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) |
Functions | |
| _MHD_EXTERN enum MHD_Result | MHD_get_connection_URI_path_n (struct MHD_Connection *connection, const char **uri, size_t *uri_size) |
| _MHD_EXTERN int | MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) |
| _MHD_EXTERN int | MHD_get_connection_values_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls) |
| _MHD_EXTERN enum MHD_Result | MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) |
| _MHD_EXTERN enum MHD_Result | MHD_set_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) |
| _MHD_EXTERN const char * | MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key) |
| _MHD_EXTERN enum MHD_Result | MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr) |
| _MHD_EXTERN struct MHD_PostProcessor * | MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls) |
| _MHD_EXTERN enum MHD_Result | MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) |
| _MHD_EXTERN enum MHD_Result | MHD_destroy_post_processor (struct MHD_PostProcessor *pp) |
| static enum MHD_Result | MHD_set_connection_value_n_nocheck_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) |
Variables | |
| enum MHD_Result | _MHD_FIXED_ENUM |
MHD API used to access information about requests.
| enum MHD_HTTP_Method _MHD_FIXED_ENUM |
Definition at line 154 of file microhttpd.h.
| typedef enum MHD_Result(* MHD_KeyValueIterator) (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
Iterator over key-value pairs. This iterator can be used to iterate over all of the cookies, headers, or POST-data fields of a request, and also to iterate over the headers that have been added to a response.
| cls | closure |
| kind | kind of the header we are looking at |
| key | key for the value, can be an empty string |
| value | corresponding value, can be NULL |
Definition at line 2794 of file microhttpd.h.
| typedef enum MHD_Result(* MHD_KeyValueIteratorN) (void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) |
Iterator over key-value pairs with size parameters. This iterator can be used to iterate over all of the cookies, headers, or POST-data fields of a request, and also to iterate over the headers that have been added to a response.
| cls | closure |
| kind | kind of the header we are looking at |
| key | key for the value, can be an empty string |
| value | corresponding value, can be NULL |
| value_size | number of bytes in value; for C-strings, the length excludes the 0-terminator |
Definition at line 2794 of file microhttpd.h.
| typedef void(* MHD_NotifyConnectionCallback) (void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe) |
Signature of the callback used by MHD to notify the application about started/stopped connections
| cls | client-defined closure |
| connection | connection handle |
| socket_context | socket-specific pointer where the client can associate some state specific to the TCP connection; note that this is different from the "req_cls" which is per HTTP request. The client can initialize during MHD_CONNECTION_NOTIFY_STARTED and cleanup during MHD_CONNECTION_NOTIFY_CLOSED and access in the meantime using MHD_CONNECTION_INFO_SOCKET_CONTEXT. |
| toe | reason for connection notification |
Definition at line 2794 of file microhttpd.h.
| typedef void(* MHD_RequestCompletedCallback) (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) |
Signature of the callback used by MHD to notify the application about completed requests.
| cls | client-defined closure |
| connection | connection handle |
| req_cls | value as set by the last call to the MHD_AccessHandlerCallback |
| toe | reason for request termination |
Definition at line 2768 of file microhttpd.h.
Values of this enum are used to specify what information about a connection is desired.
| Enumerator | |
|---|---|
| MHD_CONNECTION_INFO_CIPHER_ALGO | What cipher algorithm is being used. Takes no extra arguments. |
| MHD_CONNECTION_INFO_PROTOCOL | Takes no extra arguments. |
| MHD_CONNECTION_INFO_CLIENT_ADDRESS | Obtain IP address of the client. Takes no extra arguments. Returns essentially a |
| MHD_CONNECTION_INFO_GNUTLS_SESSION | Get the gnuTLS session handle. |
| MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT | Get the gnuTLS client certificate handle. Dysfunctional (never implemented, deprecated). Use MHD_CONNECTION_INFO_GNUTLS_SESSION to get the |
| MHD_CONNECTION_INFO_DAEMON | Get the |
| MHD_CONNECTION_INFO_CONNECTION_FD | Request the file descriptor for the connection socket. MHD sockets are always in non-blocking mode. No extra arguments should be passed. |
| MHD_CONNECTION_INFO_SOCKET_CONTEXT | Returns the client-specific pointer to a |
| MHD_CONNECTION_INFO_CONNECTION_SUSPENDED | Check whether the connection is suspended. |
| MHD_CONNECTION_INFO_CONNECTION_TIMEOUT | Get connection timeout |
| MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE | Return length of the client's HTTP request header. |
| MHD_CONNECTION_INFO_HTTP_STATUS | Return HTTP status queued with the response. NULL if no HTTP response has been queued yet. |
Definition at line 2494 of file microhttpd.h.
The enum MHD_ConnectionNotificationCode specifies types of connection notifications.
| Enumerator | |
|---|---|
| MHD_CONNECTION_NOTIFY_STARTED | A new connection has been started. |
| MHD_CONNECTION_NOTIFY_CLOSED | A connection is closed. |
Definition at line 2379 of file microhttpd.h.
The enum MHD_RequestTerminationCode specifies reasons why a request has been terminated (or completed).
| Enumerator | |
|---|---|
| MHD_REQUEST_TERMINATED_COMPLETED_OK | We finished sending the response. |
| MHD_REQUEST_TERMINATED_WITH_ERROR | Error handling the connection (resources exhausted, application error accepting request, decrypt error (for HTTPS), connection died when sending the response etc.) |
| MHD_REQUEST_TERMINATED_TIMEOUT_REACHED | No activity on the connection for the number of seconds specified using MHD_OPTION_CONNECTION_TIMEOUT. |
| MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN | We had to close the session since MHD was being shut down. |
| MHD_REQUEST_TERMINATED_READ_ERROR | We tried to read additional data, but the connection became broken or the other side hard closed the connection. This error is similar to MHD_REQUEST_TERMINATED_WITH_ERROR, but specific to the case where the connection died before request completely received. |
| MHD_REQUEST_TERMINATED_CLIENT_ABORT | The client terminated the connection by closing the socket for writing (TCP half-closed) while still sending request. |
Definition at line 2321 of file microhttpd.h.
| _MHD_EXTERN struct MHD_PostProcessor * MHD_create_post_processor | ( | struct MHD_Connection * | connection, |
| size_t | buffer_size, | ||
| MHD_PostDataIterator | iter, | ||
| void * | iter_cls ) |
Create a struct MHD_PostProcessor.
A struct MHD_PostProcessor can be used to (incrementally) parse the data portion of a POST request. Note that some buggy browsers fail to set the encoding type. If you want to support those, you may have to call MHD_set_connection_value with the proper encoding type before creating a post processor (if no supported encoding type is set, this function will fail).
| connection | the connection on which the POST is happening (used to determine the POST format) |
| buffer_size | maximum number of bytes to use for internal buffering (used only for the parsing, specifically the parsing of the keys). A tiny value (256-1024) should be sufficient. Do NOT use a value smaller than 256. For good performance, use 32 or 64k (i.e. 65536). |
| iter | iterator to be called with the parsed data, Must NOT be NULL. |
| iter_cls | first argument to iter |
Definition at line 43 of file postprocessor.c.
References _, MHD_PostProcessor::blen, MHD_PostProcessor::boundary, MHD_PostProcessor::buffer_size, MHD_PostProcessor::cls, MHD_PostProcessor::connection, MHD_PostProcessor::encoding, MHD_PostProcessor::ikvi, mhd_assert, MHD_calloc_(), MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE, MHD_HTTP_POST_ENCODING_FORM_URLENCODED, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, MHD_lookup_connection_value_n(), MHD_NO, MHD_PANIC, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_n_(), NULL, PP_Init, RN_Inactive, MHD_PostProcessor::skip_rn, and MHD_PostProcessor::state.

| _MHD_EXTERN enum MHD_Result MHD_destroy_post_processor | ( | struct MHD_PostProcessor * | pp | ) |
Release PostProcessor resources.
| pp | the PostProcessor to destroy |
Definition at line 1295 of file postprocessor.c.
References free_unmarked(), MHD_PostProcessor::have, MHD_NO, MHD_YES, NE_none, MHD_PostProcessor::nested_boundary, NULL, post_process_urlencoded(), PP_Done, PP_Init, PP_ProcessValue, MHD_PostProcessor::state, and MHD_PostProcessor::xbuf_pos.

| _MHD_EXTERN enum MHD_Result MHD_get_connection_URI_path_n | ( | struct MHD_Connection * | connection, |
| const char ** | uri, | ||
| size_t * | uri_size ) |
Get request URI path (the request target without query part).
The value obtained by this function is the same value as url provided for MHD_AccessHandlerCallback callback, but this function also provides the size of the string.
This function is critically important when binary zero is allowed by daemon option MHD_OPTION_ALLOW_BIN_ZERO_IN_URI_PATH as this is the only way to get the non-truncated request URI.
Returned uri pointer is valid until response is started or connection is terminated.
| connection | the connection to URI from | |
| [out] | uri | set to the request URI without query part, may contain binary zeros (NUL) characters, never set to NULL on success; can be NULL |
| [out] | uri_size | set to the size of the uri in bytes, not including final zero-termination; can be NULL |
Definition at line 835 of file connection.c.
References MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_CONNECTION_START_REPLY, MHD_NO, MHD_YES, NULL, MHD_Connection::rq, MHD_Connection::state, MHD_Request::url, and MHD_Request::url_len.
| _MHD_EXTERN int MHD_get_connection_values | ( | struct MHD_Connection * | connection, |
| enum MHD_ValueKind | kind, | ||
| MHD_KeyValueIterator | iterator, | ||
| void * | iterator_cls ) |
Get all of the headers from the request.
| connection | connection to get values from |
| kind | types of values to iterate over, can be a bitmask |
| iterator | callback to call on each header; may be NULL (then just count headers) |
| iterator_cls | extra argument to iterator |
Get all of the headers from the request.
| connection | connection to get values from |
| kind | types of values to iterate over, can be a bitmask |
| iterator | callback to call on each header; maybe NULL (then just count headers) |
| iterator_cls | extra argument to iterator |
Definition at line 873 of file connection.c.
References MHD_HTTP_Req_Header::header, MHD_Request::headers_received, MHD_HTTP_Req_Header::kind, MHD_NO, MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, and MHD_HTTP_Req_Header::value.
| _MHD_EXTERN int MHD_get_connection_values_n | ( | struct MHD_Connection * | connection, |
| enum MHD_ValueKind | kind, | ||
| MHD_KeyValueIteratorN | iterator, | ||
| void * | iterator_cls ) |
Get all of the headers from the request.
| connection | connection to get values from |
| kind | types of values to iterate over, can be a bitmask |
| iterator | callback to call on each header; may be NULL (then just count headers) |
| iterator_cls | extra argument to iterator |
Get all of the headers from the request.
| connection | connection to get values from |
| kind | types of values to iterate over, can be a bitmask |
| iterator | callback to call on each header; maybe NULL (then just count headers) |
| iterator_cls | extra argument to iterator |
Definition at line 912 of file connection.c.
References MHD_HTTP_Req_Header::header, MHD_HTTP_Req_Header::header_size, MHD_Request::headers_received, MHD_HTTP_Req_Header::kind, MHD_NO, MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, MHD_HTTP_Req_Header::value, and MHD_HTTP_Req_Header::value_size.
| _MHD_EXTERN const char * MHD_lookup_connection_value | ( | struct MHD_Connection * | connection, |
| enum MHD_ValueKind | kind, | ||
| const char * | key ) |
Get a particular header value. If multiple values match the kind, return any one of them.
| connection | connection to get values from |
| kind | what kind of value are we looking for |
| key | the header to look for, NULL to lookup 'trailing' value without a key |
Definition at line 1106 of file connection.c.
References MHD_HTTP_Req_Header::kind, MHD_lookup_connection_value_n(), NULL, and MHD_HTTP_Req_Header::value.

| _MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n | ( | struct MHD_Connection * | connection, |
| enum MHD_ValueKind | kind, | ||
| const char * | key, | ||
| size_t | key_size, | ||
| const char ** | value_ptr, | ||
| size_t * | value_size_ptr ) |
Get a particular header value. If multiple values match the kind, return any one of them.
| connection | connection to get values from | |
| kind | what kind of value are we looking for | |
| key | the header to look for, NULL to lookup 'trailing' value without a key | |
| key_size | the length of key in bytes | |
| [out] | value_ptr | the pointer to variable, which will be set to found value, will not be updated if key not found, could be NULL to just check for presence of key |
| [out] | value_size_ptr | the pointer variable, which will set to found value, will not be updated if key not found, could be NULL |
Definition at line 1143 of file connection.c.
References MHD_HTTP_Req_Header::header, MHD_HTTP_Req_Header::header_size, MHD_Request::headers_received, MHD_HTTP_Req_Header::kind, MHD_NO, MHD_str_equal_caseless_bin_n_(), MHD_YES, MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, MHD_HTTP_Req_Header::value, and MHD_HTTP_Req_Header::value_size.
Referenced by get_no_space_err_status_code(), MHD_create_post_processor(), MHD_lookup_connection_value(), and need_100_continue().


| _MHD_EXTERN enum MHD_Result MHD_post_process | ( | struct MHD_PostProcessor * | pp, |
| const char * | post_data, | ||
| size_t | post_data_len ) |
Parse and process POST data. Call this function when POST data is available (usually during an MHD_AccessHandlerCallback) with the "upload_data" and "upload_data_size". Whenever possible, this will then cause calls to the MHD_PostDataIterator.
| pp | the post processor |
| post_data | post_data_len bytes of POST data |
| post_data_len | length of post_data |
Definition at line 1267 of file postprocessor.c.
References MHD_PostProcessor::encoding, MHD_HTTP_POST_ENCODING_FORM_URLENCODED, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, MHD_NO, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_n_(), MHD_YES, NULL, post_process_multipart(), and post_process_urlencoded().

| _MHD_EXTERN enum MHD_Result MHD_set_connection_value | ( | struct MHD_Connection * | connection, |
| enum MHD_ValueKind | kind, | ||
| const char * | key, | ||
| const char * | value ) |
This function can be used to add an entry to the HTTP headers of a connection (so that the MHD_get_connection_values function will return them – and the struct MHD_PostProcessor will also see them). This maybe required in certain situations (see Mantis #1399) where (broken) HTTP implementations fail to supply values needed by the post processor (or other parts of the application).
This function MUST only be called from within the MHD_AccessHandlerCallback (otherwise, access maybe improperly synchronized). Furthermore, the client must guarantee that the key and value arguments are 0-terminated strings that are NOT freed until the connection is closed. (The easiest way to do this is by passing only arguments to permanently allocated strings.).
| connection | the connection for which a value should be set |
| kind | kind of the value |
| key | key for the value |
| value | the value itself |
Definition at line 1077 of file connection.c.
References MHD_HTTP_Req_Header::kind, MHD_set_connection_value_n_nocheck_(), NULL, and MHD_HTTP_Req_Header::value.

| _MHD_EXTERN enum MHD_Result MHD_set_connection_value_n | ( | struct MHD_Connection * | connection, |
| enum MHD_ValueKind | kind, | ||
| const char * | key, | ||
| size_t | key_size, | ||
| const char * | value, | ||
| size_t | value_size ) |
This function can be used to add an arbitrary entry to connection. This function could add entry with binary zero, which is allowed for MHD_GET_ARGUMENT_KIND. For other kind on entries it is recommended to use MHD_set_connection_value.
This function MUST only be called from within the MHD_AccessHandlerCallback (otherwise, access maybe improperly synchronized). Furthermore, the client must guarantee that the key and value arguments are 0-terminated strings that are NOT freed until the connection is closed. (The easiest way to do this is by passing only arguments to permanently allocated strings.).
| connection | the connection for which a value should be set |
| kind | kind of the value |
| key | key for the value, must be zero-terminated |
| key_size | number of bytes in key (excluding 0-terminator) |
| value | the value itself, must be zero-terminated |
| value_size | number of bytes in value (excluding 0-terminator) |
This function can be used to add an arbitrary entry to connection. This function could add entry with binary zero, which is allowed for MHD_GET_ARGUMENT_KIND. For other kind on entries it is recommended to use MHD_set_connection_value.
This function MUST only be called from within the MHD_AccessHandlerCallback (otherwise, access maybe improperly synchronized). Furthermore, the client must guarantee that the key and value arguments are 0-terminated strings that are NOT freed until the connection is closed. (The easiest way to do this is by passing only arguments to permanently allocated strings.).
| connection | the connection for which a value should be set |
| kind | kind of the value |
| key | key for the value, must be zero-terminated |
| key_size | number of bytes in key (excluding 0-terminator) |
| value | the value itself, must be zero-terminated |
| value_size | number of bytes in value (excluding 0-terminator) |
Definition at line 1030 of file connection.c.
References MHD_HTTP_Req_Header::kind, MHD_GET_ARGUMENT_KIND, MHD_NO, MHD_set_connection_value_n_nocheck_(), MHD_HTTP_Req_Header::value, and MHD_HTTP_Req_Header::value_size.
Referenced by connection_add_header().


|
static |
This function can be used to add an arbitrary entry to connection. Internal version of MHD_set_connection_value_n() without checking of arguments values.
| connection | the connection for which a value should be set |
| kind | kind of the value |
| key | key for the value, must be zero-terminated |
| key_size | number of bytes in key (excluding 0-terminator) |
| value | the value itself, must be zero-terminated |
| value_size | number of bytes in value (excluding 0-terminator) |
Definition at line 965 of file connection.c.
References MHD_HTTP_Req_Header::header, MHD_HTTP_Req_Header::header_size, MHD_Request::headers_received, MHD_Request::headers_received_tail, MHD_HTTP_Req_Header::kind, mhd_assert, MHD_connection_alloc_memory_(), MHD_NO, MHD_YES, MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, MHD_HTTP_Req_Header::value, and MHD_HTTP_Req_Header::value_size.
Referenced by get_req_headers(), MHD_set_connection_value(), and MHD_set_connection_value_n().


| enum MHD_CONNECTION_OPTION _MHD_FIXED_ENUM |