GNU libmicrohttpd
0.9.5
|
public interface to libmicrohttpd More...
#include <unistd.h>
#include <stdarg.h>
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
Go to the source code of this file.
Data Structures | |
struct | MHD_OptionItem |
union | MHD_ConnectionInfo |
union | MHD_DaemonInfo |
Typedefs | |
typedef void(* | MHD_PanicCallback )(void *cls, const char *file, unsigned int line, const char *reason) |
typedef int(* | MHD_AcceptPolicyCallback )(void *cls, const struct sockaddr *addr, socklen_t addrlen) |
typedef int(* | MHD_AccessHandlerCallback )(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) |
typedef void(* | MHD_RequestCompletedCallback )(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe) |
typedef int(* | MHD_KeyValueIterator )(void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
typedef ssize_t(* | MHD_ContentReaderCallback )(void *cls, uint64_t pos, char *buf, size_t max) |
typedef void(* | MHD_ContentReaderFreeCallback )(void *cls) |
typedef int(* | MHD_PostDataIterator )(void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) |
typedef void(* | MHD_UpgradeHandler )(void *cls, struct MHD_Connection *connection, void **con_cls, int upgrade_socket) |
Functions | |
struct MHD_Daemon * | MHD_start_daemon_va (unsigned int options, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap) |
struct MHD_Daemon * | MHD_start_daemon (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...) |
void | MHD_stop_daemon (struct MHD_Daemon *daemon) |
int | MHD_add_connection (struct MHD_Daemon *daemon, int client_socket, const struct sockaddr *addr, socklen_t addrlen) |
int | MHD_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *max_fd) |
int | MHD_get_timeout (struct MHD_Daemon *daemon, unsigned MHD_LONG_LONG *timeout) |
int | MHD_run (struct MHD_Daemon *daemon) |
int | MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) |
int | MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) |
void | MHD_set_panic_func (MHD_PanicCallback cb, void *cls) |
const char * | MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key) |
int | MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response) |
struct MHD_Response * | MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) |
struct MHD_Response * | MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) |
struct MHD_Response * | MHD_create_response_from_buffer (size_t size, void *buffer, enum MHD_ResponseMemoryMode mode) |
struct MHD_Response * | MHD_create_response_from_fd (size_t size, int fd) |
struct MHD_Response * | MHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset) |
void | MHD_destroy_response (struct MHD_Response *response) |
int | MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content) |
int | MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content) |
int | MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content) |
int | MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) |
const char * | MHD_get_response_header (struct MHD_Response *response, const char *key) |
struct MHD_PostProcessor * | MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *cls) |
int | MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) |
int | MHD_destroy_post_processor (struct MHD_PostProcessor *pp) |
char * | MHD_digest_auth_get_username (struct MHD_Connection *connection) |
int | MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout) |
int | MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale) |
char * | MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char **password) |
int | MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response) |
union MHD_ConnectionInfo * | MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType infoType,...) |
int | MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...) |
union MHD_DaemonInfo * | MHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType infoType,...) |
const char * | MHD_get_version (void) |
public interface to libmicrohttpd
All symbols defined in this header start with MHD. MHD is a small HTTP daemon library. As such, it does not have any API for logging errors (you can only enable or disable logging to stderr). Also, it may not support all of the HTTP features directly, where applicable, portions of HTTP may have to be handled by clients of the library.
The library is supposed to handle everything that it must handle (because the API would not allow clients to do this), such as basic connection management; however, detailed interpretations of headers – such as range requests – and HTTP methods are left to clients. The library does understand HEAD and will only send the headers of the response and not the body, even if the client supplied a body. The library also understands headers that control connection management (specifically, "Connection: close" and "Expect: 100 continue" are understood and handled automatically).
MHD understands POST data and is able to decode certain formats (at the moment only "application/x-www-form-urlencoded" and "mulitpart/formdata"). Unsupported encodings and large POST submissions may require the application to manually process the stream, which is provided to the main application (and thus can be processed, just not conveniently by MHD).
The header file defines various constants used by the HTTP protocol. This does not mean that MHD actually interprets all of these values. The provided constants are exported as a convenience for users of the library. MHD does not verify that transmitted HTTP headers are part of the standard specification; users of the library are free to define their own extensions of the HTTP standard and use those with MHD.
All functions are guaranteed to be completely reentrant and thread-safe (with the exception of 'MHD_set_connection_value', which must only be used in a particular context).
NEW: Before including "microhttpd.h" you should add the necessary includes to define the "uint64_t", "size_t", "fd_set", "socklen_t" and "struct sockaddr" data types (which headers are needed may depend on your platform; for possible suggestions consult "platform.h" in the MHD distribution). If you have done so, you should also have a line with "#define MHD_PLATFORM_H" which will prevent this header from trying (and, depending on your platform, failing) to #include the right headers.
Definition in file microhttpd.h.
#define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL) |
Definition at line 140 of file microhttpd.h.
Referenced by file_reader(), try_ready_chunked_body(), and try_ready_normal_body().
#define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1) |
Definition at line 141 of file microhttpd.h.
Referenced by file_reader(), try_ready_chunked_body(), and try_ready_normal_body().
#define MHD_HTTP_ACCEPTED 202 |
Definition at line 170 of file microhttpd.h.
#define MHD_HTTP_BAD_GATEWAY 502 |
Definition at line 216 of file microhttpd.h.
#define MHD_HTTP_BAD_REQUEST 400 |
Definition at line 186 of file microhttpd.h.
Referenced by MHD_connection_handle_idle(), parse_connection_headers(), and process_broken_line().
#define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509 |
Definition at line 222 of file microhttpd.h.
#define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS 450 |
Definition at line 211 of file microhttpd.h.
#define MHD_HTTP_CONFLICT 409 |
Definition at line 195 of file microhttpd.h.
#define MHD_HTTP_CONTINUE 100 |
HTTP response codes.
Definition at line 164 of file microhttpd.h.
#define MHD_HTTP_CREATED 201 |
Definition at line 169 of file microhttpd.h.
#define MHD_HTTP_EXPECTATION_FAILED 417 |
Definition at line 203 of file microhttpd.h.
#define MHD_HTTP_FAILED_DEPENDENCY 424 |
Definition at line 206 of file microhttpd.h.
#define MHD_HTTP_FORBIDDEN 403 |
Definition at line 189 of file microhttpd.h.
#define MHD_HTTP_FOUND 302 |
Definition at line 179 of file microhttpd.h.
#define MHD_HTTP_GATEWAY_TIMEOUT 504 |
Definition at line 218 of file microhttpd.h.
#define MHD_HTTP_GONE 410 |
Definition at line 196 of file microhttpd.h.
#define MHD_HTTP_HEADER_ACCEPT "Accept" |
Definition at line 233 of file microhttpd.h.
#define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset" |
Definition at line 234 of file microhttpd.h.
#define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding" |
Definition at line 235 of file microhttpd.h.
#define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language" |
Definition at line 236 of file microhttpd.h.
#define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges" |
Definition at line 237 of file microhttpd.h.
#define MHD_HTTP_HEADER_AGE "Age" |
Definition at line 238 of file microhttpd.h.
#define MHD_HTTP_HEADER_ALLOW "Allow" |
Definition at line 239 of file microhttpd.h.
#define MHD_HTTP_HEADER_AUTHORIZATION "Authorization" |
Definition at line 240 of file microhttpd.h.
Referenced by MHD_basic_auth_get_username_password(), MHD_digest_auth_check(), and MHD_digest_auth_get_username().
#define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control" |
Definition at line 241 of file microhttpd.h.
#define MHD_HTTP_HEADER_CONNECTION "Connection" |
Definition at line 242 of file microhttpd.h.
Referenced by add_extra_headers(), build_header_response(), and MHD_connection_handle_idle().
#define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding" |
Definition at line 243 of file microhttpd.h.
#define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language" |
Definition at line 244 of file microhttpd.h.
#define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length" |
Definition at line 245 of file microhttpd.h.
Referenced by add_extra_headers(), and parse_connection_headers().
#define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location" |
Definition at line 246 of file microhttpd.h.
#define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5" |
Definition at line 247 of file microhttpd.h.
#define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range" |
Definition at line 248 of file microhttpd.h.
#define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type" |
Definition at line 249 of file microhttpd.h.
Referenced by MHD_create_post_processor(), and test_simple_large().
#define MHD_HTTP_HEADER_COOKIE "Cookie" |
Definition at line 250 of file microhttpd.h.
Referenced by parse_cookie_header().
#define MHD_HTTP_HEADER_DATE "Date" |
Definition at line 251 of file microhttpd.h.
Referenced by build_header_response().
#define MHD_HTTP_HEADER_ETAG "ETag" |
Definition at line 252 of file microhttpd.h.
#define MHD_HTTP_HEADER_EXPECT "Expect" |
Definition at line 253 of file microhttpd.h.
Referenced by need_100_continue().
#define MHD_HTTP_HEADER_EXPIRES "Expires" |
Definition at line 254 of file microhttpd.h.
#define MHD_HTTP_HEADER_FROM "From" |
Definition at line 255 of file microhttpd.h.
#define MHD_HTTP_HEADER_HOST "Host" |
Definition at line 256 of file microhttpd.h.
Referenced by parse_connection_headers().
#define MHD_HTTP_HEADER_IF_MATCH "If-Match" |
Definition at line 257 of file microhttpd.h.
#define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since" |
Definition at line 258 of file microhttpd.h.
#define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match" |
Definition at line 259 of file microhttpd.h.
#define MHD_HTTP_HEADER_IF_RANGE "If-Range" |
Definition at line 260 of file microhttpd.h.
#define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since" |
Definition at line 261 of file microhttpd.h.
#define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified" |
Definition at line 262 of file microhttpd.h.
#define MHD_HTTP_HEADER_LOCATION "Location" |
Definition at line 263 of file microhttpd.h.
#define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards" |
Definition at line 264 of file microhttpd.h.
#define MHD_HTTP_HEADER_PRAGMA "Pragma" |
Definition at line 265 of file microhttpd.h.
#define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate" |
Definition at line 266 of file microhttpd.h.
#define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization" |
Definition at line 267 of file microhttpd.h.
#define MHD_HTTP_HEADER_RANGE "Range" |
Definition at line 268 of file microhttpd.h.
#define MHD_HTTP_HEADER_REFERER "Referer" |
Definition at line 269 of file microhttpd.h.
#define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After" |
Definition at line 270 of file microhttpd.h.
#define MHD_HTTP_HEADER_SERVER "Server" |
Definition at line 271 of file microhttpd.h.
#define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie" |
Definition at line 272 of file microhttpd.h.
#define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2" |
Definition at line 273 of file microhttpd.h.
#define MHD_HTTP_HEADER_TE "TE" |
Definition at line 274 of file microhttpd.h.
#define MHD_HTTP_HEADER_TRAILER "Trailer" |
Definition at line 275 of file microhttpd.h.
#define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding" |
Definition at line 276 of file microhttpd.h.
Referenced by add_extra_headers(), and parse_connection_headers().
#define MHD_HTTP_HEADER_UPGRADE "Upgrade" |
Definition at line 277 of file microhttpd.h.
#define MHD_HTTP_HEADER_USER_AGENT "User-Agent" |
Definition at line 278 of file microhttpd.h.
#define MHD_HTTP_HEADER_VARY "Vary" |
Definition at line 279 of file microhttpd.h.
#define MHD_HTTP_HEADER_VIA "Via" |
Definition at line 280 of file microhttpd.h.
#define MHD_HTTP_HEADER_WARNING "Warning" |
Definition at line 281 of file microhttpd.h.
#define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate" |
Definition at line 282 of file microhttpd.h.
Referenced by MHD_queue_auth_fail_response(), and MHD_queue_basic_auth_fail_response().
#define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505 |
Definition at line 219 of file microhttpd.h.
#define MHD_HTTP_INSUFFICIENT_STORAGE 507 |
Definition at line 221 of file microhttpd.h.
#define MHD_HTTP_INTERNAL_SERVER_ERROR 500 |
Definition at line 214 of file microhttpd.h.
Referenced by MHD_connection_get_pollfd().
#define MHD_HTTP_LENGTH_REQUIRED 411 |
Definition at line 197 of file microhttpd.h.
#define MHD_HTTP_LOCKED 423 |
Definition at line 205 of file microhttpd.h.
#define MHD_HTTP_METHOD_CONNECT "CONNECT" |
HTTP methods
Definition at line 294 of file microhttpd.h.
#define MHD_HTTP_METHOD_DELETE "DELETE" |
Definition at line 295 of file microhttpd.h.
#define MHD_HTTP_METHOD_GET "GET" |
Definition at line 296 of file microhttpd.h.
#define MHD_HTTP_METHOD_HEAD "HEAD" |
Definition at line 297 of file microhttpd.h.
Referenced by MHD_queue_response().
#define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406 |
Definition at line 192 of file microhttpd.h.
#define MHD_HTTP_METHOD_NOT_ALLOWED 405 |
Definition at line 191 of file microhttpd.h.
#define MHD_HTTP_METHOD_OPTIONS "OPTIONS" |
Definition at line 298 of file microhttpd.h.
#define MHD_HTTP_METHOD_POST "POST" |
Definition at line 299 of file microhttpd.h.
#define MHD_HTTP_METHOD_PUT "PUT" |
Definition at line 300 of file microhttpd.h.
#define MHD_HTTP_METHOD_TRACE "TRACE" |
Definition at line 301 of file microhttpd.h.
#define MHD_HTTP_MOVED_PERMANENTLY 301 |
Definition at line 178 of file microhttpd.h.
#define MHD_HTTP_MULTI_STATUS 207 |
Definition at line 175 of file microhttpd.h.
#define MHD_HTTP_MULTIPLE_CHOICES 300 |
Definition at line 177 of file microhttpd.h.
#define MHD_HTTP_NO_CONTENT 204 |
Definition at line 172 of file microhttpd.h.
#define MHD_HTTP_NO_RESPONSE 444 |
Definition at line 209 of file microhttpd.h.
#define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203 |
Definition at line 171 of file microhttpd.h.
#define MHD_HTTP_NOT_EXTENDED 510 |
Definition at line 223 of file microhttpd.h.
#define MHD_HTTP_NOT_FOUND 404 |
Definition at line 190 of file microhttpd.h.
#define MHD_HTTP_NOT_IMPLEMENTED 501 |
Definition at line 215 of file microhttpd.h.
#define MHD_HTTP_NOT_MODIFIED 304 |
Definition at line 181 of file microhttpd.h.
#define MHD_HTTP_OK 200 |
Definition at line 168 of file microhttpd.h.
#define MHD_HTTP_PARTIAL_CONTENT 206 |
Definition at line 174 of file microhttpd.h.
#define MHD_HTTP_PAYMENT_REQUIRED 402 |
Definition at line 188 of file microhttpd.h.
#define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded" |
HTTP POST encodings, see also http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
Definition at line 307 of file microhttpd.h.
Referenced by MHD_create_post_processor(), MHD_post_process(), and test_simple_large().
#define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data" |
Definition at line 308 of file microhttpd.h.
Referenced by MHD_create_post_processor(), and MHD_post_process().
#define MHD_HTTP_PRECONDITION_FAILED 412 |
Definition at line 198 of file microhttpd.h.
#define MHD_HTTP_PROCESSING 102 |
Definition at line 166 of file microhttpd.h.
#define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407 |
Definition at line 193 of file microhttpd.h.
#define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413 |
Definition at line 199 of file microhttpd.h.
Referenced by connection_add_header(), get_next_header_line(), MHD_connection_get_pollfd(), parse_cookie_header(), and process_broken_line().
#define MHD_HTTP_REQUEST_TIMEOUT 408 |
Definition at line 194 of file microhttpd.h.
#define MHD_HTTP_REQUEST_URI_TOO_LONG 414 |
Definition at line 200 of file microhttpd.h.
Referenced by get_next_header_line(), and MHD_connection_get_pollfd().
#define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416 |
Definition at line 202 of file microhttpd.h.
#define MHD_HTTP_RESET_CONTENT 205 |
Definition at line 173 of file microhttpd.h.
#define MHD_HTTP_RETRY_WITH 449 |
Definition at line 210 of file microhttpd.h.
#define MHD_HTTP_SEE_OTHER 303 |
Definition at line 180 of file microhttpd.h.
#define MHD_HTTP_SERVICE_UNAVAILABLE 503 |
Definition at line 217 of file microhttpd.h.
#define MHD_HTTP_SWITCH_PROXY 306 |
Definition at line 183 of file microhttpd.h.
#define MHD_HTTP_SWITCHING_PROTOCOLS 101 |
Definition at line 165 of file microhttpd.h.
#define MHD_HTTP_TEMPORARY_REDIRECT 307 |
Definition at line 184 of file microhttpd.h.
#define MHD_HTTP_UNAUTHORIZED 401 |
Definition at line 187 of file microhttpd.h.
Referenced by MHD_queue_auth_fail_response(), and MHD_queue_basic_auth_fail_response().
#define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451 |
Definition at line 212 of file microhttpd.h.
#define MHD_HTTP_UNORDERED_COLLECTION 425 |
Definition at line 207 of file microhttpd.h.
#define MHD_HTTP_UNPROCESSABLE_ENTITY 422 |
Definition at line 204 of file microhttpd.h.
#define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415 |
Definition at line 201 of file microhttpd.h.
#define MHD_HTTP_UPGRADE_REQUIRED 426 |
Definition at line 208 of file microhttpd.h.
#define MHD_HTTP_USE_PROXY 305 |
Definition at line 182 of file microhttpd.h.
#define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506 |
Definition at line 220 of file microhttpd.h.
#define MHD_HTTP_VERSION_1_0 "HTTP/1.0" |
HTTP versions (used to match against the first line of the HTTP header as well as in the response code).
Definition at line 288 of file microhttpd.h.
Referenced by build_header_response(), and transmit_error_response().
#define MHD_HTTP_VERSION_1_1 "HTTP/1.1" |
Definition at line 289 of file microhttpd.h.
Referenced by add_extra_headers(), build_header_response(), MHD_connection_handle_idle(), need_100_continue(), and parse_connection_headers().
#define MHD_ICY_FLAG ((uint32_t)(1 << 31)) |
Flag to be "OR"ed with MHD_HTTP status code for SHOUTcast. This will cause the response to begin with the SHOUTcast "ICY" line instad of "HTTP".
Definition at line 230 of file microhttpd.h.
Referenced by build_header_response().
#define MHD_INVALID_NONCE -1 |
MHD digest auth internal code for an invalid nonce.
Constant to indicate that the nonce of the provided authentication code was wrong.
Definition at line 1607 of file microhttpd.h.
Referenced by MHD_digest_auth_check().
#define MHD_INVALID_NONCE -1 |
MHD digest auth internal code for an invalid nonce.
Constant to indicate that the nonce of the provided authentication code was wrong.
Definition at line 1607 of file microhttpd.h.
#define MHD_LONG_LONG long long |
Not all architectures and printf's support the long long type. This gives the ability to replace long long with just a long, standard int or a short.
Definition at line 150 of file microhttpd.h.
Referenced by add_extra_headers(), MHD_select(), and parse_connection_headers().
#define MHD_LONG_LONG_PRINTF "ll" |
Format string for printing a variable of type 'MHD_LONG_LONG'. You should only redefine this if you also define MHD_LONG_LONG.
Definition at line 157 of file microhttpd.h.
Referenced by add_extra_headers().
#define MHD_NO 0 |
MHD-internal return code for "NO".
Definition at line 119 of file microhttpd.h.
Referenced by add_extra_headers(), add_response_entry(), build_header_response(), call_connection_handler(), check_argument_match(), check_nonce_nc(), check_write_done(), connection_add_header(), do_read(), do_write(), find_boundary(), MHD_accept_connection(), MHD_add_connection(), MHD_cleanup_connections(), MHD_connection_close(), MHD_connection_get_pollfd(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_del_response_header(), MHD_destroy_post_processor(), MHD_digest_auth_check(), MHD_get_fdset(), MHD_get_timeout(), MHD_handle_connection(), MHD_ip_addr_to_key(), MHD_ip_limit_add(), MHD_ip_limit_del(), MHD_poll(), MHD_pool_create(), MHD_pool_destroy(), MHD_post_process(), MHD_queue_auth_fail_response(), MHD_queue_response(), MHD_run(), MHD_select(), MHD_set_connection_option(), MHD_set_connection_value(), parse_arguments(), parse_cookie_header(), parse_initial_message_line(), parse_options_va(), post_process_multipart(), post_process_urlencoded(), process_broken_line(), process_header_line(), process_multipart_headers(), process_request_body(), process_value_to_boundary(), run_tls_handshake(), test_header(), transmit_error_response(), try_grow_read_buffer(), try_match_header(), try_ready_chunked_body(), and try_ready_normal_body().
#define MHD_SIZE_UNKNOWN ((uint64_t) -1LL) |
Constant used to indicate unknown size (use when creating a response).
Definition at line 133 of file microhttpd.h.
Referenced by add_extra_headers(), MHD_connection_handle_idle(), parse_connection_headers(), and process_request_body().
#define MHD_VERSION 0x00091600 |
Current version of the library.
Definition at line 109 of file microhttpd.h.
#define MHD_YES 1 |
MHD-internal return code for "YES".
Definition at line 114 of file microhttpd.h.
Referenced by add_extra_headers(), add_response_entry(), build_header_response(), call_connection_handler(), check_argument_match(), check_nonce_nc(), check_write_done(), close_all_connections(), connection_add_header(), do_read(), do_write(), find_boundary(), MHD_accept_connection(), MHD_add_connection(), MHD_connection_close(), MHD_connection_get_fdset(), MHD_connection_get_pollfd(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_connection_handle_write(), MHD_create_response_from_data(), MHD_del_response_header(), MHD_destroy_post_processor(), MHD_digest_auth_check(), MHD_get_connection_values(), MHD_get_fdset(), MHD_get_response_headers(), MHD_get_timeout(), MHD_handle_connection(), MHD_ip_addr_to_key(), MHD_ip_limit_add(), MHD_poll(), MHD_pool_allocate(), MHD_pool_create(), MHD_post_process(), MHD_queue_auth_fail_response(), MHD_queue_basic_auth_fail_response(), MHD_queue_response(), MHD_run(), MHD_select(), MHD_select_thread(), MHD_set_connection_option(), MHD_set_connection_value(), MHD_start_daemon_va(), MHD_stop_daemon(), MHD_tls_connection_handle_idle(), MHD_tls_connection_handle_read(), MHD_tls_connection_handle_write(), parse_arguments(), parse_connection_headers(), parse_cookie_header(), parse_initial_message_line(), parse_options_va(), post_process_multipart(), post_process_urlencoded(), process_broken_line(), process_header_line(), process_multipart_headers(), process_request_body(), process_value_to_boundary(), run_tls_handshake(), test_header(), transmit_error_response(), try_grow_read_buffer(), try_match_header(), try_ready_chunked_body(), try_ready_normal_body(), and value_checker().
typedef int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen) |
Allow or deny a client to connect.
addr | address information from the client |
addrlen | length of the address information |
Definition at line 853 of file microhttpd.h.
typedef int(* MHD_AccessHandlerCallback)(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) |
A client has requested the given url using the given method ("GET", "PUT", "DELETE", "POST", etc). The callback must call MHS callbacks to provide content to give back to the client and return an HTTP status code (i.e. 200 for OK, 404, etc.).
cls | argument given together with the function pointer when the handler was registered with MHD |
url | the requested url |
method | the HTTP method used ("GET", "PUT", etc.) |
version | the HTTP version string (i.e. "HTTP/1.1") |
upload_data | the data being uploaded (excluding HEADERS, for a POST that fits into memory and that is encoded with a supported encoding, the POST data will NOT be given in upload_data and is instead available as part of MHD_get_connection_values; very large POST data will be made available incrementally in upload_data) |
upload_data_size | set initially to the size of the upload_data provided; the method must update this value to the number of bytes NOT processed; |
con_cls | pointer that the callback can set to some address and that will be preserved by MHD for future calls for this request; since the access handler may be called many times (i.e., for a PUT/POST operation with plenty of upload data) this allows the application to easily associate some request-specific state. If necessary, this state can be cleaned up in the global "MHD_RequestCompleted" callback (which can be set with the MHD_OPTION_NOTIFY_COMPLETED). Initially, *con_cls will be NULL. |
Definition at line 894 of file microhttpd.h.
typedef ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max) |
Callback used by libmicrohttpd in order to obtain content. The callback is to copy at most "max" bytes of content into "buf". The total number of bytes that has been placed into "buf" should be returned.
Note that returning zero will cause libmicrohttpd to try again, either "immediately" if in multi-threaded mode (in which case the callback may want to do blocking operations) or in the next round if MHD_run is used. Returning 0 for a daemon that runs in internal select mode is an error (since it would result in busy waiting) and will cause the program to be aborted (abort()).
cls | extra argument to the callback |
pos | position in the datastream to access; note that if an MHD_Response object is re-used, it is possible for the same content reader to be queried multiple times for the same data; however, if an MHD_Response is not re-used, libmicrohttpd guarantees that "pos" will be the sum of all non-negative return values obtained from the content reader so far. |
buf | where to copy the data |
max | maximum number of bytes to copy to buf (size of buf) |
Definition at line 986 of file microhttpd.h.
typedef void(* MHD_ContentReaderFreeCallback)(void *cls) |
This method is called by libmicrohttpd if we are done with a content reader. It should be used to free resources associated with the content reader.
Definition at line 999 of file microhttpd.h.
typedef int(* 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.
Definition at line 933 of file microhttpd.h.
typedef void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason) |
Callback for serious error condition. The default action is to print an error message and abort().
cls | user specified value |
file | where the error occured |
line | where the error occured |
reason | error detail, may be NULL |
Definition at line 840 of file microhttpd.h.
typedef int(* MHD_PostDataIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) |
Iterator over key-value pairs where the value maybe made available in increments and/or may not be zero-terminated. Used for processing POST data.
cls | user-specified closure |
kind | type of the value |
key | 0-terminated key for the value |
filename | name of the uploaded file, NULL if not known |
content_type | mime-type of the data, NULL if not known |
transfer_encoding | encoding of the data, NULL if not known |
data | pointer to size bytes of data at the specified offset |
off | offset of data in the overall value |
size | number of bytes in data available |
Definition at line 1022 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 916 of file microhttpd.h.
typedef void(* MHD_UpgradeHandler)(void *cls, struct MHD_Connection *connection, void **con_cls, int upgrade_socket) |
Function called after a protocol upgrade response was sent successfully and the socket should now be controlled by some protocol other than HTTP. Note that from this point on, MHD will consider this connection to be "complete", so it will no longer be counted as an active connection for the MHD_OPTION_PER_IP_CONNECTION_LIMIT or the MHD_OPTION_CONNECTION_LIMIT. After this function returns, the MHD_RequestCompletedCallback will be called and all resources of the connection (except for the socket itself) will be released.
cls | closure |
connection | original HTTP connection handle, giving the function a last chance to inspect the original HTTP request |
con_cls | value as set by the last call to the MHD_AccessHandlerCallback; will afterwards be also given to the MHD_RequestCompletedCallback |
upgrade_socket | TCP socket that was upgraded from HTTP to some other protocol. This function must take over the communication and is ultimately responsible for closing the socket. |
Definition at line 1424 of file microhttpd.h.
MHD connection options. Given to 'MHD_set_connection_option' to set custom options for a particular connection.
MHD_CONNECTION_OPTION_TIMEOUT |
Set a custom timeout for the given connection. Specified as the number of seconds, given as an 'unsigned int'. Use zero for no timeout. |
Definition at line 1745 of file microhttpd.h.
Values of this enum are used to specify what information about a connection is desired.
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 "struct sockaddr **" (since the API returns a "union MHD_ConnectionInfo *" and that union contains a "struct sockaddr *"). |
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 gnutls_session_t and then call gnutls_certificate_get_peers(). |
MHD_CONNECTION_INFO_DAEMON |
Get the 'struct MHD_Daemon' responsible for managing this connection. |
Definition at line 733 of file microhttpd.h.
enum MHD_DaemonInfoType |
Values of this enum are used to specify what information about a deamon is desired.
Definition at line 780 of file microhttpd.h.
enum MHD_FLAG |
Options for the MHD daemon. Note that if neither MHD_USE_THREAD_PER_CONNECTION nor MHD_USE_SELECT_INTERNALLY is used, the client wants control over the process and will call the appropriate microhttpd callbacks.
Starting the daemon may also fail if a particular option is not implemented or not supported on the target platform (i.e. no support for SSL, threads or IPv6).
Definition at line 320 of file microhttpd.h.
enum MHD_OPTION |
MHD options. Passed in the varargs portion of MHD_start_daemon.
MHD_OPTION_END |
No more options / last option. This is used to terminate the VARARGs list. |
MHD_OPTION_CONNECTION_MEMORY_LIMIT |
Maximum memory size per connection (followed by a size_t). |
MHD_OPTION_CONNECTION_LIMIT |
Maximum number of concurrent connections to accept (followed by an unsigned int). |
MHD_OPTION_CONNECTION_TIMEOUT |
After how many seconds of inactivity should a connection automatically be timed out? (followed by an unsigned int; use zero for no timeout). |
MHD_OPTION_NOTIFY_COMPLETED |
Register a function that should be called whenever a request has been completed (this can be used for application-specific clean up). Requests that have never been presented to the application (via MHD_AccessHandlerCallback) will not result in notifications. This option should be followed by TWO pointers. First a pointer to a function of type "MHD_RequestCompletedCallback" and second a pointer to a closure to pass to the request completed callback. The second pointer maybe NULL. |
MHD_OPTION_PER_IP_CONNECTION_LIMIT |
Limit on the number of (concurrent) connections made to the server from the same IP address. Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. The option should be followed by an "unsigned int". The default is zero, which means no limit on the number of connections from the same IP address. |
MHD_OPTION_SOCK_ADDR |
Bind daemon to the supplied sockaddr. this option should be followed by a 'struct sockaddr *'. If 'MHD_USE_IPv6' is specified, the 'struct sockaddr*' should point to a 'struct sockaddr_in6', otherwise to a 'struct sockaddr_in'. |
MHD_OPTION_URI_LOG_CALLBACK |
Specify a function that should be called before parsing the URI from the client. The specified callback function can be used for processing the URI (including the options) before it is parsed. The URI after parsing will no longer contain the options, which maybe inconvenient for logging. This option should be followed by two arguments, the first one must be of the form void * my_logger(void * cls, const char * uri) where the return value will be passed as (*con_cls) in calls to the MHD_AccessHandlerCallback when this request is processed later; returning a value of NULL has no special significance (however, note that if you return non-NULL, you can no longer rely on the first call to the access handler having NULL == *con_cls on entry;) "cls" will be set to the second argument following MHD_OPTION_URI_LOG_CALLBACK. Finally, uri will be the 0-terminated URI of the request. |
MHD_OPTION_HTTPS_MEM_KEY |
Memory pointer for the private key (key.pem) to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_CERT'. |
MHD_OPTION_HTTPS_MEM_CERT |
Memory pointer for the certificate (cert.pem) to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. |
MHD_OPTION_HTTPS_CRED_TYPE |
Daemon credentials type. Followed by an argument of type "gnutls_credentials_type_t". |
MHD_OPTION_HTTPS_PRIORITIES |
Memory pointer to a "const char*" specifying the cipher algorithm (default: "NORMAL"). |
MHD_OPTION_LISTEN_SOCKET |
Pass a listen socket for MHD to use (systemd-style). If this option is used, MHD will not open its own listen socket(s). The argument passed must be of type "int" and refer to an existing socket that has been bound to a port and is listening. |
MHD_OPTION_EXTERNAL_LOGGER |
Use the given function for logging error messages. This option must be followed by two arguments; the first must be a pointer to a function of type "void fun(void * arg, const char * fmt, va_list ap)" and the second a pointer "void*" which will be passed as the "arg" argument to "fun". Note that MHD will not generate any log messages if it was compiled without the "–enable-messages" flag being set. |
MHD_OPTION_THREAD_POOL_SIZE |
Number (unsigned int) of threads in thread pool. Enable thread pooling by setting this value to to something greater than 1. Currently, thread model must be MHD_USE_SELECT_INTERNALLY if thread pooling is enabled (MHD_start_daemon returns NULL for an unsupported thread model). |
MHD_OPTION_ARRAY |
Additional options given in an array of "struct MHD_OptionItem". The array must be terminated with an entry '{MHD_OPTION_END, 0, NULL}'. An example for code using MHD_OPTION_ARRAY is: |
MHD_OPTION_UNESCAPE_CALLBACK |
Specify a function that should be called for unescaping escape sequences in URIs and URI arguments. Note that this function will NOT be used by the MHD_PostProcessor. If this option is not specified, the default method will be used which decodes escape sequences of the form "%HH". This option should be followed by two arguments, the first one must be of the form size_t my_unescaper(void * cls, struct MHD_Connection *c, char *s) where the return value must be "strlen(s)" and "s" should be updated. Note that the unescape function must not lengthen "s" (the result must be shorter than the input and still be 0-terminated). "cls" will be set to the second argument following MHD_OPTION_UNESCAPE_CALLBACK. |
MHD_OPTION_DIGEST_AUTH_RANDOM |
Memory pointer for the random values to be used by the Digest Auth module. This option should be followed by two arguments. First an integer of type "size_t" which specifies the size of the buffer pointed to by the second argument in bytes. Note that the application must ensure that the buffer of the second argument remains allocated and unmodified while the deamon is running. |
MHD_OPTION_NONCE_NC_SIZE |
Size of the internal array holding the map of the nonce and the nonce counter. This option should be followed by a "unsigend int" argument. |
MHD_OPTION_THREAD_STACK_SIZE |
Desired size of the stack for threads created by MHD. Followed by an argument of type 'size_t'. Use 0 for system 'default'. |
MHD_OPTION_HTTPS_MEM_TRUST |
Memory pointer for the certificate (ca.pem) to be used by the HTTPS daemon for client authentification. This option should be followed by a "const char*" argument. |
Definition at line 394 of file microhttpd.h.
The MHD_RequestTerminationCode specifies reasons why a request has been terminated (or completed).
Definition at line 689 of file microhttpd.h.
Specification for how MHD should treat the memory buffer given for the response.
Definition at line 1323 of file microhttpd.h.
enum MHD_ValueKind |
The MHD_ValueKind specifies the source of the key-value pairs in the HTTP protocol.
Definition at line 644 of file microhttpd.h.
int MHD_add_connection | ( | struct MHD_Daemon * | daemon, |
int | client_socket, | ||
const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client.
The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards.
daemon | daemon that manages the connection |
client_socket | socket to manage (MHD will expect to receive an HTTP request from this socket next). |
addr | IP address of the client |
addrlen | number of bytes in addr |
Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client.
The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards.
Per-IP connection limits are ignored when using this API.
daemon | daemon that manages the connection |
client_socket | socket to manage (MHD will expect to receive an HTTP request from this socket next). |
addr | IP address of the client |
addrlen | number of bytes in addr |
Definition at line 855 of file daemon.c.
References MHD_Connection::addr, MHD_Connection::addr_len, MHD_Daemon::apc, MHD_Daemon::apc_cls, MHD_Daemon::cleanup_connection_mutex, CLOSE, MHD_Connection::connection_timeout, MHD_Daemon::connection_timeout, MHD_Daemon::connections_head, MHD_Daemon::connections_tail, create_thread(), MHD_Connection::daemon, DLL_insert, DLL_remove, MHD_Connection::last_activity, MHD_Daemon::max_connections, MHD_handle_connection(), MHD_ip_limit_add(), MHD_ip_limit_del(), MHD_monotonic_time(), MHD_NO, MHD_PANIC, MHD_set_http_callbacks_(), MHD_set_https_callbacks(), MHD_TLS_CONNECTION_INIT, MHD_USE_POLL, MHD_USE_SSL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Daemon::options, MHD_Connection::pid, MHD_Connection::pool, MHD_Connection::recv_cls, recv_param_adapter(), MHD_Connection::send_cls, send_param_adapter(), SHUTDOWN, MHD_Connection::socket_fd, MHD_Connection::state, and STRERROR.
Referenced by MHD_accept_connection().
int MHD_add_response_footer | ( | struct MHD_Response * | response, |
const char * | footer, | ||
const char * | content | ||
) |
Add a footer line to the response.
response | response to remove a header from |
footer | the footer to delete |
content | value to delete |
Definition at line 108 of file response.c.
References add_response_entry(), and MHD_FOOTER_KIND.
int MHD_add_response_header | ( | struct MHD_Response * | response, |
const char * | header, | ||
const char * | content | ||
) |
Add a header line to the response.
response | response to add a header to |
header | the header to add |
content | value to add |
Add a header line to the response.
response | response to add a header to |
header | the header to add |
content | value to add |
Definition at line 89 of file response.c.
References add_response_entry(), and MHD_HEADER_KIND.
Referenced by add_extra_headers(), MHD_queue_auth_fail_response(), and MHD_queue_basic_auth_fail_response().
char* MHD_basic_auth_get_username_password | ( | struct MHD_Connection * | connection, |
char ** | password | ||
) |
Get the username and password from the basic authorization header sent by the client
connection | The MHD connection structure |
password | a pointer for the password |
Definition at line 45 of file basicauth.c.
References _BASIC_BASE, BASE64Decode(), MHD_Connection::daemon, MHD_HEADER_KIND, MHD_HTTP_HEADER_AUTHORIZATION, MHD_lookup_connection_value(), and NULL.
|
read |
Create a PostProcessor.
A 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. |
iter | iterator to be called with the parsed data, Must NOT be NULL. |
cls | first argument to ikvi |
Create a PostProcessor.
A PostProcessor can be used to (incrementally) parse the data portion of a POST request.
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 0. |
ikvi | iterator to be called with the parsed data |
cls | first argument to ikvi |
Definition at line 252 of file postprocessor.c.
References MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE, MHD_HTTP_POST_ENCODING_FORM_URLENCODED, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, MHD_lookup_connection_value(), mhd_panic, mhd_panic_cls, NULL, PP_Init, and RN_Inactive.
Referenced by test_simple_large().
|
read |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
buffer | size bytes containing the response's data portion |
mode | flags for buffer management |
Definition at line 401 of file response.c.
References MHD_create_response_from_data(), MHD_RESPMEM_MUST_COPY, and MHD_RESPMEM_MUST_FREE.
Referenced by parse_connection_headers(), and transmit_error_response().
|
read |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response, MHD_SIZE_UNKNOWN for unknown |
block_size | preferred block size for querying crc (advisory only, MHD may still call crc using smaller chunks); this is essentially the buffer size used for IO, clients should pick a value that is appropriate for IO and memory performance requirements |
crc | callback to use to obtain response data |
crc_cls | extra argument to crc |
crfc | callback to call to free crc_cls resources |
Definition at line 221 of file response.c.
References MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::data, MHD_Response::data_buffer_size, MHD_Response::fd, MHD_Response::mutex, NULL, MHD_Response::reference_count, and MHD_Response::total_size.
Referenced by MHD_create_response_from_fd_at_offset().
|
read |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
data | the data itself |
must_free | libmicrohttpd should free data when done |
must_copy | libmicrohttpd must make a copy of data right away, the data maybe released anytime after this call returns |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
data | the data itself |
must_free | libmicrohttpd should free data when done |
must_copy | libmicrohttpd must make a copy of data right away, the data maybe released anytime after this call returns |
Definition at line 351 of file response.c.
References MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::data, MHD_Response::data_size, MHD_Response::fd, MHD_YES, MHD_Response::mutex, NULL, MHD_Response::reference_count, and MHD_Response::total_size.
Referenced by MHD_create_response_from_buffer().
|
read |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
fd | file descriptor referring to a file on disk with the data; will be closed when response is destroyed; fd should be in 'blocking' mode |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
fd | file descriptor referring to a file on disk with the data |
Definition at line 330 of file response.c.
References MHD_create_response_from_fd_at_offset().
|
read |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
fd | file descriptor referring to a file on disk with the data; will be closed when response is destroyed; fd should be in 'blocking' mode |
off | offset to start reading from in the file; Be careful! 'off_t' may have been compiled to be a 64-bit variable for MHD, in which case your application also has to be compiled using the same options! Read the MHD manual for more details. |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
fd | file descriptor referring to a file on disk with the data |
off | offset to start reading from in the file |
Definition at line 302 of file response.c.
References MHD_Response::crc_cls, MHD_Response::fd, MHD_Response::fd_off, file_reader(), free_callback(), MHD_create_response_from_callback(), and NULL.
Referenced by MHD_create_response_from_fd().
int MHD_del_response_header | ( | struct MHD_Response * | response, |
const char * | header, | ||
const char * | content | ||
) |
Delete a header (or footer) line from the response.
response | response to remove a header from |
header | the header to delete |
content | value to delete |
Delete a header line from the response.
response | response to remove a header from |
header | the header to delete |
content | value to delete |
Definition at line 127 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_NO, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
int MHD_destroy_post_processor | ( | struct MHD_PostProcessor * | pp | ) |
Release PostProcessor resources.
pp | the PostProcessor to destroy |
Release PostProcessor resources.
Definition at line 1056 of file postprocessor.c.
References free_unmarked(), MHD_NO, MHD_YES, NE_none, NULL, and PP_Done.
Referenced by test_simple_large().
void MHD_destroy_response | ( | struct MHD_Response * | response | ) |
Destroy a response object and associated resources. Note that libmicrohttpd may keep some of the resources around if the response is still in the queue for some clients, so the memory may not necessarily be freed immediatley.
response | response to destroy |
Destroy a response object and associated resources. Note that libmicrohttpd may keep some of the resources around if the response is still in the queue for some clients, so the memory may not necessarily be freed immediatley.
Definition at line 419 of file response.c.
References MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::first_header, MHD_HTTP_Header::header, MHD_Response::mutex, MHD_HTTP_Header::next, NULL, MHD_Response::reference_count, and MHD_HTTP_Header::value.
Referenced by MHD_cleanup_connections(), MHD_connection_handle_idle(), MHD_handle_connection(), parse_connection_headers(), and transmit_error_response().
int MHD_digest_auth_check | ( | struct MHD_Connection * | connection, |
const char * | realm, | ||
const char * | username, | ||
const char * | password, | ||
unsigned int | nonce_timeout | ||
) |
Authenticates the authorization header sent by the client
connection | The MHD connection structure |
realm | The realm presented to the client |
username | The username needs to be authenticated |
password | The password used in the authentication |
nonce_timeout | The amount of time for a nonce to be invalid in seconds |
Definition at line 546 of file digestauth.c.
References _BASE, calculate_nonce(), check_argument_match(), check_nonce_nc(), MHD_Connection::daemon, digest_calc_ha1(), digest_calc_response(), HASH_MD5_HEX_LEN, MHD_HTTP_Header::header, lookup_sub_value(), MAX_AUTH_RESPONSE_LENGTH, MAX_NONCE_LENGTH, MAX_REALM_LENGTH, MAX_USERNAME_LENGTH, MHD_Connection::method, MHD_HEADER_KIND, MHD_HTTP_HEADER_AUTHORIZATION, MHD_INVALID_NONCE, MHD_lookup_connection_value(), MHD_monotonic_time(), MHD_NO, MHD_YES, NULL, and MHD_Connection::url.
char* MHD_digest_auth_get_username | ( | struct MHD_Connection * | connection | ) |
Get the username from the authorization header sent by the client
connection | The MHD connection structure |
Definition at line 353 of file digestauth.c.
References _BASE, lookup_sub_value(), MAX_USERNAME_LENGTH, MHD_HEADER_KIND, MHD_HTTP_HEADER_AUTHORIZATION, MHD_lookup_connection_value(), and NULL.
|
write |
Obtain information about the given connection.
connection | what connection to get information about |
infoType | what information is desired? |
... | depends on infoType |
Definition at line 2471 of file connection.c.
References MHD_Connection::addr, MHD_Connection::daemon, MHD_CONNECTION_INFO_CIPHER_ALGO, MHD_CONNECTION_INFO_CLIENT_ADDRESS, MHD_CONNECTION_INFO_DAEMON, MHD_CONNECTION_INFO_GNUTLS_SESSION, MHD_CONNECTION_INFO_PROTOCOL, and NULL.
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 |
iterator | callback to call on each header; maybe NULL (then just count headers) |
iterator_cls | extra argument to iterator |
Definition at line 119 of file connection.c.
References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
|
write |
Obtain information about the given daemon (not fully implemented!).
daemon | what daemon to get information about |
infoType | what information is desired? |
... | depends on infoType |
Definition at line 2724 of file daemon.c.
References MHD_DAEMON_INFO_LISTEN_FD, NULL, and MHD_Daemon::socket_fd.
int MHD_get_fdset | ( | struct MHD_Daemon * | daemon, |
fd_set * | read_fd_set, | ||
fd_set * | write_fd_set, | ||
fd_set * | except_fd_set, | ||
int * | max_fd | ||
) |
Obtain the select sets for this daemon.
daemon | daemon to get sets from |
read_fd_set | read set |
write_fd_set | write set |
except_fd_set | except set |
max_fd | increased to largest FD added (if larger than existing value); can be NULL |
Definition at line 522 of file daemon.c.
References MHD_Daemon::connections_head, MHD_connection_get_fdset(), MHD_NO, MHD_USE_POLL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Connection::next, NULL, MHD_Daemon::options, MHD_Daemon::shutdown, and MHD_Daemon::socket_fd.
Referenced by MHD_select().
const char* MHD_get_response_header | ( | struct MHD_Response * | response, |
const char * | key | ||
) |
Get a particular header (or footer) from the response.
response | response to query |
key | which header to get |
Get a particular header from the response.
key | which header to get |
Definition at line 192 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
Referenced by add_extra_headers(), build_header_response(), and MHD_connection_handle_idle().
int MHD_get_response_headers | ( | struct MHD_Response * | response, |
MHD_KeyValueIterator | iterator, | ||
void * | iterator_cls | ||
) |
Get all of the headers (and footers) added to a response.
response | response to query |
iterator | callback to call on each header; maybe NULL (then just count headers) |
iterator_cls | extra argument to iterator |
Get all of the headers added to a response.
iterator | callback to call on each header; maybe NULL (then just count headers) |
iterator_cls | extra argument to iterator |
Definition at line 167 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::kind, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
int MHD_get_timeout | ( | struct MHD_Daemon * | daemon, |
unsigned MHD_LONG_LONG * | timeout | ||
) |
Obtain timeout value for select for this daemon (only needed if connection timeout is used). The returned value is how long select should at most block, not the timeout value set for connections. This function MUST NOT be called if MHD is running with "MHD_USE_THREAD_PER_CONNECTION".
daemon | daemon to query for timeout |
timeout | set to the timeout (in milliseconds) |
Obtain timeout value for select for this daemon (only needed if connection timeout is used). The returned value is how long select should at most block, not the timeout value set for connections.
daemon | daemon to query for timeout |
timeout | set to the timeout (in milliseconds) |
Definition at line 1253 of file daemon.c.
References MHD_Connection::connection_timeout, MHD_Daemon::connections_head, MHD_Connection::last_activity, MHD_monotonic_time(), MHD_NO, MHD_USE_SSL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Connection::next, NULL, and MHD_Daemon::options.
Referenced by MHD_select().
const char* MHD_get_version | ( | void | ) |
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 211 of file connection.c.
References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
Referenced by MHD_basic_auth_get_username_password(), MHD_connection_handle_idle(), MHD_create_post_processor(), MHD_digest_auth_check(), MHD_digest_auth_get_username(), need_100_continue(), parse_connection_headers(), and parse_cookie_header().
int 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_IncrementalKeyValueIterator.
pp | the post processor |
post_data | post_data_len bytes of POST data |
post_data_len | length of post_data |
Definition at line 1034 of file postprocessor.c.
References MHD_HTTP_POST_ENCODING_FORM_URLENCODED, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, MHD_NO, MHD_YES, NULL, post_process_multipart(), and post_process_urlencoded().
Referenced by test_simple_large().
int MHD_queue_auth_fail_response | ( | struct MHD_Connection * | connection, |
const char * | realm, | ||
const char * | opaque, | ||
struct MHD_Response * | response, | ||
int | signal_stale | ||
) |
Queues a response to request authentication from the client
connection | The MHD connection structure |
realm | The realm presented to the client |
opaque | string to user for opaque value |
response | reply to send; should contain the "access denied" body; note that this function will set the "WWW Authenticate" header and that the caller should not do this |
signal_stale | MHD_YES if the nonce is invalid to add 'stale=true' to the authentication header |
Queues a response to request authentication from the client
connection | The MHD connection structure |
realm | the realm presented to the client |
opaque | string to user for opaque value |
signal_stale | MHD_YES if the nonce is invalid to add 'stale=true' to the authentication header |
Definition at line 744 of file digestauth.c.
References calculate_nonce(), check_nonce_nc(), MHD_Connection::daemon, HASH_MD5_HEX_LEN, MHD_HTTP_Header::header, MHD_Connection::method, MHD_add_response_header(), MHD_HTTP_HEADER_WWW_AUTHENTICATE, MHD_HTTP_UNAUTHORIZED, MHD_monotonic_time(), MHD_NO, MHD_queue_response(), MHD_YES, NULL, and MHD_Connection::url.
int MHD_queue_basic_auth_fail_response | ( | struct MHD_Connection * | connection, |
const char * | realm, | ||
struct MHD_Response * | response | ||
) |
Queues a response to request basic authentication from the client
connection | The MHD connection structure |
realm | the realm presented to the client |
Definition at line 110 of file basicauth.c.
References MHD_add_response_header(), MHD_HTTP_HEADER_WWW_AUTHENTICATE, MHD_HTTP_UNAUTHORIZED, MHD_queue_response(), and MHD_YES.
int MHD_queue_response | ( | struct MHD_Connection * | connection, |
unsigned int | status_code, | ||
struct MHD_Response * | response | ||
) |
Queue a response to be transmitted to the client (as soon as possible but after MHD_AccessHandlerCallback returns).
connection | the connection identifying the client |
status_code | HTTP status code (i.e. 200 for OK) |
response | response to transmit |
Definition at line 240 of file connection.c.
References MHD_Connection::method, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_HTTP_METHOD_HEAD, MHD_increment_response_rc(), MHD_NO, MHD_YES, NULL, MHD_Connection::read_closed, MHD_Connection::response, MHD_Connection::response_write_position, MHD_Connection::responseCode, SHUTDOWN, MHD_Connection::socket_fd, MHD_Connection::state, and MHD_Response::total_size.
Referenced by MHD_queue_auth_fail_response(), MHD_queue_basic_auth_fail_response(), parse_connection_headers(), and transmit_error_response().
int MHD_run | ( | struct MHD_Daemon * | daemon | ) |
Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used.
daemon | daemon to run |
Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used.
Definition at line 1614 of file daemon.c.
References MHD_cleanup_connections(), MHD_NO, MHD_poll(), MHD_select(), MHD_USE_POLL, MHD_USE_SELECT_INTERNALLY, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Daemon::options, and MHD_Daemon::shutdown.
int MHD_set_connection_option | ( | struct MHD_Connection * | connection, |
enum MHD_CONNECTION_OPTION | option, | ||
... | |||
) |
Set a custom option for the given connection, overriding defaults.
connection | connection to modify |
option | option to set |
... | arguments to the option, depending on the option type |
Definition at line 2511 of file connection.c.
References MHD_Connection::connection_timeout, MHD_CONNECTION_OPTION_TIMEOUT, MHD_NO, and MHD_YES.
int 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 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 |
This function can be used to append an entry to the list of HTTP headers of a connection (so that the MHD_get_connection_values function will return them – and the 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 172 of file connection.c.
References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_Connection::headers_received_tail, MHD_HTTP_Header::kind, MHD_NO, MHD_pool_allocate(), MHD_YES, MHD_HTTP_Header::next, NULL, MHD_Connection::pool, and MHD_HTTP_Header::value.
Referenced by connection_add_header().
void MHD_set_panic_func | ( | MHD_PanicCallback | cb, |
void * | cls | ||
) |
Sets the global error handler to a different implementation. "cb" will only be called in the case of typically fatal, serious internal consistency issues. These issues should only arise in the case of serious memory corruption or similar problems with the architecture. While "cb" is allowed to return and MHD will then try to continue, this is never safe.
The default implementation that is used if no panic function is set simply prints an error message and calls "abort". Alternative implementations might call "exit" or other similar functions.
cb | new error handler |
cls | passed to error handler |
Definition at line 2753 of file daemon.c.
References mhd_panic, and mhd_panic_cls.
|
read |
Start a webserver on the given port. Variadic version of MHD_start_daemon_va.
flags | combination of MHD_FLAG values |
port | port to bind to |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted |
apc_cls | extra argument to apc |
dh | handler called for all requests (repeatedly) |
dh_cls | extra argument to dh |
Start a webserver on the given port.
port | port to bind to |
apc | callback to call to check which clients will be allowed to connect |
apc_cls | extra argument to apc |
dh | default handler for all URIs |
dh_cls | extra argument to dh |
Definition at line 1665 of file daemon.c.
References MHD_start_daemon_va().
|
read |
Start a webserver on the given port.
flags | combination of MHD_FLAG values |
port | port to bind to |
apc | callback to call to check which clients will be allowed to connect; you can pass NULL in which case connections from any IP will be accepted |
apc_cls | extra argument to apc |
dh | handler called for all requests (repeatedly) |
dh_cls | extra argument to dh |
... | list of options (type-value pairs, terminated with MHD_OPTION_END). |
Start a webserver on the given port.
port | port to bind to |
apc | callback to call to check which clients will be allowed to connect |
apc_cls | extra argument to apc |
dh | default handler for all URIs |
dh_cls | extra argument to dh |
Definition at line 2058 of file daemon.c.
References MHD_Daemon::apc, MHD_Daemon::apc_cls, BIND, MHD_Daemon::cleanup_connection_mutex, CLOSE, MHD_Daemon::connection_timeout, create_socket(), create_thread(), MHD_Daemon::default_handler, MHD_Daemon::default_handler_cls, LISTEN, MHD_Daemon::master, MHD_Daemon::max_connections, MHD_http_unescape(), MHD_MAX_CONNECTIONS_DEFAULT, MHD_POOL_SIZE_DEFAULT, MHD_select_thread(), MHD_stop_daemon(), MHD_USE_DEBUG, MHD_USE_IPv6, MHD_USE_NO_LISTEN_SOCKET, MHD_USE_POLL, MHD_USE_SELECT_INTERNALLY, MHD_USE_SSL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Daemon::options, parse_options_va(), MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, PIPE, MHD_Daemon::pool_size, MHD_Daemon::port, SETSOCKOPT, MHD_Daemon::socket_fd, STRERROR, MHD_Daemon::unescape_callback, MHD_Daemon::worker_pool, MHD_Daemon::worker_pool_size, and MHD_Daemon::wpipe.
Referenced by MHD_start_daemon().
void MHD_stop_daemon | ( | struct MHD_Daemon * | daemon | ) |
Shutdown an http daemon.
daemon | daemon to stop |
Shutdown an http daemon
daemon | daemon to stop |
Definition at line 2614 of file daemon.c.
References MHD_Daemon::cleanup_connection_mutex, CLOSE, close_all_connections(), MHD_PANIC, MHD_USE_SELECT_INTERNALLY, MHD_USE_SSL, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Daemon::options, MHD_Daemon::per_ip_connection_mutex, MHD_Daemon::pid, SHUTDOWN, MHD_Daemon::shutdown, MHD_Daemon::socket_fd, MHD_Daemon::worker_pool, MHD_Daemon::worker_pool_size, MHD_Daemon::wpipe, and WRITE.
Referenced by MHD_start_daemon_va().