GNU libmicrohttpd
0.9.72
|
Typedefs | |
typedef void(* | MHD_RequestCompletedCallback) (void *cls, struct MHD_Connection *connection, void **con_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 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) |
const struct MHD_Action * | MHD_action_parse_post (size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls) |
unsigned int | MHD_request_get_values (struct MHD_Request *request, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) |
enum MHD_Bool | MHD_request_set_value (struct MHD_Request *request, enum MHD_ValueKind kind, const char *key, const char *value) |
const char * | MHD_request_lookup_value (struct MHD_Request *request, enum MHD_ValueKind kind, const char *key) |
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) |
MHD API used to access information about requests.
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 2238 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, NEW since MHD_VERSION 0x00096301; for C-strings, the length excludes the 0-terminator |
Definition at line 2238 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 "con_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 2238 of file microhttpd.h.
typedef void(* MHD_RequestCompletedCallback) (void *cls, struct MHD_Connection *connection, void **con_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 |
con_cls | value as set by the last call to the MHD_AccessHandlerCallback |
toe | reason for request termination |
Definition at line 2212 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. |
Definition at line 1979 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 1889 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, other side closed connection, application error accepting request, 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 other side closed the connection. This error is similar to MHD_REQUEST_TERMINATED_WITH_ERROR, but specific to the case where the connection died because the other side did not send expected data. |
MHD_REQUEST_TERMINATED_CLIENT_ABORT | The client terminated the connection by closing the socket for writing (TCP half-closed); MHD aborted sending the response according to RFC 2616, section 8.1.4. |
Definition at line 1831 of file microhttpd.h.
const struct MHD_Action* MHD_action_parse_post | ( | size_t | buffer_size, |
MHD_PostDataIterator | iter, | ||
void * | iter_cls | ||
) |
Create an action that parses a POST request.
This action 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 returning this action (if no supported encoding type is detected, returning this action will cause a bad request to be returned to the client).
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 53 of file action_parse_post.c.
References NULL.
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 280 of file postprocessor.c.
References 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_panic_cls, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_n_(), NULL, PP_Init, and RN_Inactive.
enum MHD_Result MHD_destroy_post_processor | ( | struct MHD_PostProcessor * | pp | ) |
Release PostProcessor resources.
pp | the PostProcessor to destroy |
Release PostProcessor resources.
pp | post processor context to destroy |
Definition at line 1102 of file postprocessor.c.
References find_boundary(), free_unmarked(), MHD_NO, mhd_panic, mhd_panic_cls, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_n_(), MHD_YES, NE_content_filename, NE_content_name, NE_content_transfer_encoding, NE_content_type, NE_none, NULL, PP_Done, PP_Error, PP_Init, PP_Nested_Init, PP_Nested_PerformCleanup, PP_Nested_PerformMarking, PP_Nested_ProcessEntryHeaders, PP_Nested_ProcessValueToBoundary, PP_NextBoundary, PP_PerformCheckMultipart, PP_PerformCleanup, PP_ProcessEntryHeaders, PP_ProcessValueToBoundary, process_multipart_headers(), process_value_to_boundary(), RN_Dash, RN_Dash2, RN_Full, RN_Inactive, and RN_OptN.
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; maybe 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 194 of file connection.c.
References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_NO, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
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; maybe NULL (then just count headers) |
iterator_cls | extra argument to iterator |
Definition at line 233 of file connection.c.
References MHD_HTTP_Header::header, MHD_HTTP_Header::header_size, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_NO, MHD_HTTP_Header::next, NULL, MHD_HTTP_Header::value, and MHD_HTTP_Header::value_size.
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 423 of file connection.c.
References MHD_HTTP_Header::kind, MHD_lookup_connection_value_n(), NULL, and MHD_HTTP_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 459 of file connection.c.
References MHD_HTTP_Header::header, MHD_HTTP_Header::header_size, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_NO, MHD_str_equal_caseless_bin_n_(), MHD_YES, MHD_HTTP_Header::next, NULL, MHD_HTTP_Header::value, and MHD_HTTP_Header::value_size.
Referenced by digest_auth_check_all(), MHD_basic_auth_get_username_password(), MHD_create_post_processor(), MHD_digest_auth_get_username(), MHD_lookup_connection_value(), need_100_continue(), and parse_connection_headers().
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 1102 of file postprocessor.c.
unsigned int MHD_request_get_values | ( | struct MHD_Request * | request, |
enum MHD_ValueKind | kind, | ||
MHD_KeyValueIterator | iterator, | ||
void * | iterator_cls | ||
) |
Get all of the headers from the request.
request | request 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 42 of file request.c.
References MHD_HTTP_Header::header, MHD_Request::headers_received, MHD_HTTP_Header::kind, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
const char* MHD_request_lookup_value | ( | struct MHD_Request * | request, |
enum MHD_ValueKind | kind, | ||
const char * | key | ||
) |
Get a particular header value. If multiple values match the kind, return any one of them.
request | request 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 138 of file request.c.
References MHD_HTTP_Header::header, MHD_Request::headers_received, MHD_HTTP_Header::kind, MHD_str_equal_caseless_(), MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
Referenced by need_100_continue(), parse_cookie_header(), and parse_request_headers().
enum MHD_Bool MHD_request_set_value | ( | struct MHD_Request * | request, |
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 request (so that the MHD_request_get_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 request callbacks (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.).
request | the request for which a value should be set |
kind | kind of the value |
key | key for the value |
value | the value itself |
Definition at line 42 of file request.c.
Referenced by request_add_header().
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 233 of file connection.c.
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) |
Definition at line 233 of file connection.c.
|
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 233 of file connection.c.