GNU libmicrohttpd  0.9.5
microhttpd.h File Reference

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>
Include dependency graph for microhttpd.h:

Go to the source code of this file.

Data Structures

struct  MHD_OptionItem
 
union  MHD_ConnectionInfo
 
union  MHD_DaemonInfo
 

Macros

#define MHD_VERSION   0x00092100
 
#define MHD_YES   1
 
#define MHD_NO   0
 
#define MHD_INVALID_NONCE   -1
 
#define MHD_SIZE_UNKNOWN   ((uint64_t) -1LL)
 
#define MHD_CONTENT_READER_END_OF_STREAM   ((size_t) -1LL)
 
#define MHD_CONTENT_READER_END_WITH_ERROR   (((size_t) -1LL) - 1)
 
#define MHD_LONG_LONG   long long
 
#define MHD_UNSIGNED_LONG_LONG   unsigned long long
 
#define MHD_LONG_LONG_PRINTF   "ll"
 
#define MHD_UNSIGNED_LONG_LONG_PRINTF   "%llu"
 
#define MHD_HTTP_CONTINUE   100
 
#define MHD_HTTP_SWITCHING_PROTOCOLS   101
 
#define MHD_HTTP_PROCESSING   102
 
#define MHD_HTTP_OK   200
 
#define MHD_HTTP_CREATED   201
 
#define MHD_HTTP_ACCEPTED   202
 
#define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION   203
 
#define MHD_HTTP_NO_CONTENT   204
 
#define MHD_HTTP_RESET_CONTENT   205
 
#define MHD_HTTP_PARTIAL_CONTENT   206
 
#define MHD_HTTP_MULTI_STATUS   207
 
#define MHD_HTTP_MULTIPLE_CHOICES   300
 
#define MHD_HTTP_MOVED_PERMANENTLY   301
 
#define MHD_HTTP_FOUND   302
 
#define MHD_HTTP_SEE_OTHER   303
 
#define MHD_HTTP_NOT_MODIFIED   304
 
#define MHD_HTTP_USE_PROXY   305
 
#define MHD_HTTP_SWITCH_PROXY   306
 
#define MHD_HTTP_TEMPORARY_REDIRECT   307
 
#define MHD_HTTP_BAD_REQUEST   400
 
#define MHD_HTTP_UNAUTHORIZED   401
 
#define MHD_HTTP_PAYMENT_REQUIRED   402
 
#define MHD_HTTP_FORBIDDEN   403
 
#define MHD_HTTP_NOT_FOUND   404
 
#define MHD_HTTP_METHOD_NOT_ALLOWED   405
 
#define MHD_HTTP_METHOD_NOT_ACCEPTABLE   406
 
#define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED   407
 
#define MHD_HTTP_REQUEST_TIMEOUT   408
 
#define MHD_HTTP_CONFLICT   409
 
#define MHD_HTTP_GONE   410
 
#define MHD_HTTP_LENGTH_REQUIRED   411
 
#define MHD_HTTP_PRECONDITION_FAILED   412
 
#define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE   413
 
#define MHD_HTTP_REQUEST_URI_TOO_LONG   414
 
#define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE   415
 
#define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE   416
 
#define MHD_HTTP_EXPECTATION_FAILED   417
 
#define MHD_HTTP_UNPROCESSABLE_ENTITY   422
 
#define MHD_HTTP_LOCKED   423
 
#define MHD_HTTP_FAILED_DEPENDENCY   424
 
#define MHD_HTTP_UNORDERED_COLLECTION   425
 
#define MHD_HTTP_UPGRADE_REQUIRED   426
 
#define MHD_HTTP_NO_RESPONSE   444
 
#define MHD_HTTP_RETRY_WITH   449
 
#define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS   450
 
#define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS   451
 
#define MHD_HTTP_INTERNAL_SERVER_ERROR   500
 
#define MHD_HTTP_NOT_IMPLEMENTED   501
 
#define MHD_HTTP_BAD_GATEWAY   502
 
#define MHD_HTTP_SERVICE_UNAVAILABLE   503
 
#define MHD_HTTP_GATEWAY_TIMEOUT   504
 
#define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED   505
 
#define MHD_HTTP_VARIANT_ALSO_NEGOTIATES   506
 
#define MHD_HTTP_INSUFFICIENT_STORAGE   507
 
#define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED   509
 
#define MHD_HTTP_NOT_EXTENDED   510
 
#define MHD_ICY_FLAG   ((uint32_t)(1 << 31))
 
#define MHD_HTTP_HEADER_ACCEPT   "Accept"
 
#define MHD_HTTP_HEADER_ACCEPT_CHARSET   "Accept-Charset"
 
#define MHD_HTTP_HEADER_ACCEPT_ENCODING   "Accept-Encoding"
 
#define MHD_HTTP_HEADER_ACCEPT_LANGUAGE   "Accept-Language"
 
#define MHD_HTTP_HEADER_ACCEPT_RANGES   "Accept-Ranges"
 
#define MHD_HTTP_HEADER_AGE   "Age"
 
#define MHD_HTTP_HEADER_ALLOW   "Allow"
 
#define MHD_HTTP_HEADER_AUTHORIZATION   "Authorization"
 
#define MHD_HTTP_HEADER_CACHE_CONTROL   "Cache-Control"
 
#define MHD_HTTP_HEADER_CONNECTION   "Connection"
 
#define MHD_HTTP_HEADER_CONTENT_ENCODING   "Content-Encoding"
 
#define MHD_HTTP_HEADER_CONTENT_LANGUAGE   "Content-Language"
 
#define MHD_HTTP_HEADER_CONTENT_LENGTH   "Content-Length"
 
#define MHD_HTTP_HEADER_CONTENT_LOCATION   "Content-Location"
 
#define MHD_HTTP_HEADER_CONTENT_MD5   "Content-MD5"
 
#define MHD_HTTP_HEADER_CONTENT_RANGE   "Content-Range"
 
#define MHD_HTTP_HEADER_CONTENT_TYPE   "Content-Type"
 
#define MHD_HTTP_HEADER_COOKIE   "Cookie"
 
#define MHD_HTTP_HEADER_DATE   "Date"
 
#define MHD_HTTP_HEADER_ETAG   "ETag"
 
#define MHD_HTTP_HEADER_EXPECT   "Expect"
 
#define MHD_HTTP_HEADER_EXPIRES   "Expires"
 
#define MHD_HTTP_HEADER_FROM   "From"
 
#define MHD_HTTP_HEADER_HOST   "Host"
 
#define MHD_HTTP_HEADER_IF_MATCH   "If-Match"
 
#define MHD_HTTP_HEADER_IF_MODIFIED_SINCE   "If-Modified-Since"
 
#define MHD_HTTP_HEADER_IF_NONE_MATCH   "If-None-Match"
 
#define MHD_HTTP_HEADER_IF_RANGE   "If-Range"
 
#define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE   "If-Unmodified-Since"
 
#define MHD_HTTP_HEADER_LAST_MODIFIED   "Last-Modified"
 
#define MHD_HTTP_HEADER_LOCATION   "Location"
 
#define MHD_HTTP_HEADER_MAX_FORWARDS   "Max-Forwards"
 
#define MHD_HTTP_HEADER_PRAGMA   "Pragma"
 
#define MHD_HTTP_HEADER_PROXY_AUTHENTICATE   "Proxy-Authenticate"
 
#define MHD_HTTP_HEADER_PROXY_AUTHORIZATION   "Proxy-Authorization"
 
#define MHD_HTTP_HEADER_RANGE   "Range"
 
#define MHD_HTTP_HEADER_REFERER   "Referer"
 
#define MHD_HTTP_HEADER_RETRY_AFTER   "Retry-After"
 
#define MHD_HTTP_HEADER_SERVER   "Server"
 
#define MHD_HTTP_HEADER_SET_COOKIE   "Set-Cookie"
 
#define MHD_HTTP_HEADER_SET_COOKIE2   "Set-Cookie2"
 
#define MHD_HTTP_HEADER_TE   "TE"
 
#define MHD_HTTP_HEADER_TRAILER   "Trailer"
 
#define MHD_HTTP_HEADER_TRANSFER_ENCODING   "Transfer-Encoding"
 
#define MHD_HTTP_HEADER_UPGRADE   "Upgrade"
 
#define MHD_HTTP_HEADER_USER_AGENT   "User-Agent"
 
#define MHD_HTTP_HEADER_VARY   "Vary"
 
#define MHD_HTTP_HEADER_VIA   "Via"
 
#define MHD_HTTP_HEADER_WARNING   "Warning"
 
#define MHD_HTTP_HEADER_WWW_AUTHENTICATE   "WWW-Authenticate"
 
#define MHD_HTTP_VERSION_1_0   "HTTP/1.0"
 
#define MHD_HTTP_VERSION_1_1   "HTTP/1.1"
 
#define MHD_HTTP_METHOD_CONNECT   "CONNECT"
 
#define MHD_HTTP_METHOD_DELETE   "DELETE"
 
#define MHD_HTTP_METHOD_GET   "GET"
 
#define MHD_HTTP_METHOD_HEAD   "HEAD"
 
#define MHD_HTTP_METHOD_OPTIONS   "OPTIONS"
 
#define MHD_HTTP_METHOD_POST   "POST"
 
#define MHD_HTTP_METHOD_PUT   "PUT"
 
#define MHD_HTTP_METHOD_TRACE   "TRACE"
 
#define MHD_HTTP_POST_ENCODING_FORM_URLENCODED   "application/x-www-form-urlencoded"
 
#define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA   "multipart/form-data"
 
#define MHD_INVALID_NONCE   -1
 

Typedefs

typedef void(* MHD_LogCallback )(void *cls, const char *fm, va_list ap)
 
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)
 

Enumerations

enum  MHD_FLAG {
  MHD_NO_FLAG = 0, MHD_USE_DEBUG = 1, MHD_USE_SSL = 2, MHD_USE_THREAD_PER_CONNECTION = 4,
  MHD_USE_SELECT_INTERNALLY = 8, MHD_USE_IPv6 = 16, MHD_USE_PEDANTIC_CHECKS = 32, MHD_USE_POLL = 64,
  MHD_SUPPRESS_DATE_NO_CLOCK = 128, MHD_USE_NO_LISTEN_SOCKET = 256
}
 
enum  MHD_OPTION {
  MHD_OPTION_END = 0, MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1, MHD_OPTION_CONNECTION_LIMIT = 2, MHD_OPTION_CONNECTION_TIMEOUT = 3,
  MHD_OPTION_NOTIFY_COMPLETED = 4, MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5, MHD_OPTION_SOCK_ADDR = 6, MHD_OPTION_URI_LOG_CALLBACK = 7,
  MHD_OPTION_HTTPS_MEM_KEY = 8, MHD_OPTION_HTTPS_MEM_CERT = 9, MHD_OPTION_HTTPS_CRED_TYPE = 10, MHD_OPTION_HTTPS_PRIORITIES = 11,
  MHD_OPTION_LISTEN_SOCKET = 12, MHD_OPTION_EXTERNAL_LOGGER = 13, MHD_OPTION_THREAD_POOL_SIZE = 14, MHD_OPTION_ARRAY = 15,
  MHD_OPTION_UNESCAPE_CALLBACK = 16, MHD_OPTION_DIGEST_AUTH_RANDOM = 17, MHD_OPTION_NONCE_NC_SIZE = 18, MHD_OPTION_THREAD_STACK_SIZE = 19,
  MHD_OPTION_HTTPS_MEM_TRUST =20
}
 
enum  MHD_ValueKind {
  MHD_RESPONSE_HEADER_KIND = 0, MHD_HEADER_KIND = 1, MHD_COOKIE_KIND = 2, MHD_POSTDATA_KIND = 4,
  MHD_GET_ARGUMENT_KIND = 8, MHD_FOOTER_KIND = 16
}
 
enum  MHD_RequestTerminationCode {
  MHD_REQUEST_TERMINATED_COMPLETED_OK = 0, MHD_REQUEST_TERMINATED_WITH_ERROR = 1, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2, MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3,
  MHD_REQUEST_TERMINATED_READ_ERROR = 4
}
 
enum  MHD_ConnectionInfoType {
  MHD_CONNECTION_INFO_CIPHER_ALGO, MHD_CONNECTION_INFO_PROTOCOL, MHD_CONNECTION_INFO_CLIENT_ADDRESS, MHD_CONNECTION_INFO_GNUTLS_SESSION,
  MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT, MHD_CONNECTION_INFO_DAEMON
}
 
enum  MHD_DaemonInfoType { MHD_DAEMON_INFO_KEY_SIZE, MHD_DAEMON_INFO_MAC_KEY_SIZE, MHD_DAEMON_INFO_LISTEN_FD }
 
enum  MHD_ResponseMemoryMode { MHD_RESPMEM_PERSISTENT, MHD_RESPMEM_MUST_FREE, MHD_RESPMEM_MUST_COPY }
 
enum  MHD_CONNECTION_OPTION { MHD_CONNECTION_OPTION_TIMEOUT }
 

Functions

struct MHD_Daemon * MHD_start_daemon_va (unsigned int flags, 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,...)
 
int MHD_quiesce_daemon (struct MHD_Daemon *daemon)
 
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, MHD_UNSIGNED_LONG_LONG *timeout)
 
int MHD_run (struct MHD_Daemon *daemon)
 
int MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set)
 
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 *iter_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_ConnectionInfoMHD_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_DaemonInfoMHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType infoType,...)
 
const char * MHD_get_version (void)
 

Detailed Description

public interface to libmicrohttpd

Author
Christian Grothoff
Chris GauthierDickey

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.

Macro Definition Documentation

#define MHD_CONTENT_READER_END_OF_STREAM   ((size_t) -1LL)

Definition at line 140 of file microhttpd.h.

#define MHD_CONTENT_READER_END_WITH_ERROR   (((size_t) -1LL) - 1)

Definition at line 141 of file microhttpd.h.

#define MHD_HTTP_ACCEPTED   202

Definition at line 178 of file microhttpd.h.

#define MHD_HTTP_BAD_GATEWAY   502

Definition at line 224 of file microhttpd.h.

#define MHD_HTTP_BAD_REQUEST   400

Definition at line 194 of file microhttpd.h.

#define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED   509

Definition at line 230 of file microhttpd.h.

#define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS   450

Definition at line 219 of file microhttpd.h.

#define MHD_HTTP_CONFLICT   409

Definition at line 203 of file microhttpd.h.

#define MHD_HTTP_CONTINUE   100

HTTP response codes.

Definition at line 172 of file microhttpd.h.

#define MHD_HTTP_CREATED   201

Definition at line 177 of file microhttpd.h.

#define MHD_HTTP_EXPECTATION_FAILED   417

Definition at line 211 of file microhttpd.h.

#define MHD_HTTP_FAILED_DEPENDENCY   424

Definition at line 214 of file microhttpd.h.

#define MHD_HTTP_FORBIDDEN   403

Definition at line 197 of file microhttpd.h.

#define MHD_HTTP_FOUND   302

Definition at line 187 of file microhttpd.h.

#define MHD_HTTP_GATEWAY_TIMEOUT   504

Definition at line 226 of file microhttpd.h.

#define MHD_HTTP_GONE   410

Definition at line 204 of file microhttpd.h.

#define MHD_HTTP_HEADER_ACCEPT   "Accept"

Definition at line 241 of file microhttpd.h.

#define MHD_HTTP_HEADER_ACCEPT_CHARSET   "Accept-Charset"

Definition at line 242 of file microhttpd.h.

#define MHD_HTTP_HEADER_ACCEPT_ENCODING   "Accept-Encoding"

Definition at line 243 of file microhttpd.h.

#define MHD_HTTP_HEADER_ACCEPT_LANGUAGE   "Accept-Language"

Definition at line 244 of file microhttpd.h.

#define MHD_HTTP_HEADER_ACCEPT_RANGES   "Accept-Ranges"

Definition at line 245 of file microhttpd.h.

#define MHD_HTTP_HEADER_AGE   "Age"

Definition at line 246 of file microhttpd.h.

#define MHD_HTTP_HEADER_ALLOW   "Allow"

Definition at line 247 of file microhttpd.h.

#define MHD_HTTP_HEADER_AUTHORIZATION   "Authorization"

Definition at line 248 of file microhttpd.h.

#define MHD_HTTP_HEADER_CACHE_CONTROL   "Cache-Control"

Definition at line 249 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONNECTION   "Connection"

Definition at line 250 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_ENCODING   "Content-Encoding"

Definition at line 251 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_LANGUAGE   "Content-Language"

Definition at line 252 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_LENGTH   "Content-Length"

Definition at line 253 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_LOCATION   "Content-Location"

Definition at line 254 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_MD5   "Content-MD5"

Definition at line 255 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_RANGE   "Content-Range"

Definition at line 256 of file microhttpd.h.

#define MHD_HTTP_HEADER_CONTENT_TYPE   "Content-Type"

Definition at line 257 of file microhttpd.h.

#define MHD_HTTP_HEADER_COOKIE   "Cookie"

Definition at line 258 of file microhttpd.h.

#define MHD_HTTP_HEADER_DATE   "Date"

Definition at line 259 of file microhttpd.h.

#define MHD_HTTP_HEADER_ETAG   "ETag"

Definition at line 260 of file microhttpd.h.

#define MHD_HTTP_HEADER_EXPECT   "Expect"

Definition at line 261 of file microhttpd.h.

#define MHD_HTTP_HEADER_EXPIRES   "Expires"

Definition at line 262 of file microhttpd.h.

#define MHD_HTTP_HEADER_FROM   "From"

Definition at line 263 of file microhttpd.h.

#define MHD_HTTP_HEADER_HOST   "Host"

Definition at line 264 of file microhttpd.h.

#define MHD_HTTP_HEADER_IF_MATCH   "If-Match"

Definition at line 265 of file microhttpd.h.

#define MHD_HTTP_HEADER_IF_MODIFIED_SINCE   "If-Modified-Since"

Definition at line 266 of file microhttpd.h.

#define MHD_HTTP_HEADER_IF_NONE_MATCH   "If-None-Match"

Definition at line 267 of file microhttpd.h.

#define MHD_HTTP_HEADER_IF_RANGE   "If-Range"

Definition at line 268 of file microhttpd.h.

#define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE   "If-Unmodified-Since"

Definition at line 269 of file microhttpd.h.

#define MHD_HTTP_HEADER_LAST_MODIFIED   "Last-Modified"

Definition at line 270 of file microhttpd.h.

#define MHD_HTTP_HEADER_LOCATION   "Location"

Definition at line 271 of file microhttpd.h.

#define MHD_HTTP_HEADER_MAX_FORWARDS   "Max-Forwards"

Definition at line 272 of file microhttpd.h.

#define MHD_HTTP_HEADER_PRAGMA   "Pragma"

Definition at line 273 of file microhttpd.h.

#define MHD_HTTP_HEADER_PROXY_AUTHENTICATE   "Proxy-Authenticate"

Definition at line 274 of file microhttpd.h.

#define MHD_HTTP_HEADER_PROXY_AUTHORIZATION   "Proxy-Authorization"

Definition at line 275 of file microhttpd.h.

#define MHD_HTTP_HEADER_RANGE   "Range"

Definition at line 276 of file microhttpd.h.

#define MHD_HTTP_HEADER_REFERER   "Referer"

Definition at line 278 of file microhttpd.h.

#define MHD_HTTP_HEADER_RETRY_AFTER   "Retry-After"

Definition at line 279 of file microhttpd.h.

#define MHD_HTTP_HEADER_SERVER   "Server"

Definition at line 280 of file microhttpd.h.

#define MHD_HTTP_HEADER_SET_COOKIE   "Set-Cookie"

Definition at line 281 of file microhttpd.h.

#define MHD_HTTP_HEADER_SET_COOKIE2   "Set-Cookie2"

Definition at line 282 of file microhttpd.h.

#define MHD_HTTP_HEADER_TE   "TE"

Definition at line 283 of file microhttpd.h.

#define MHD_HTTP_HEADER_TRAILER   "Trailer"

Definition at line 284 of file microhttpd.h.

#define MHD_HTTP_HEADER_TRANSFER_ENCODING   "Transfer-Encoding"

Definition at line 285 of file microhttpd.h.

#define MHD_HTTP_HEADER_UPGRADE   "Upgrade"

Definition at line 286 of file microhttpd.h.

#define MHD_HTTP_HEADER_USER_AGENT   "User-Agent"

Definition at line 287 of file microhttpd.h.

#define MHD_HTTP_HEADER_VARY   "Vary"

Definition at line 288 of file microhttpd.h.

#define MHD_HTTP_HEADER_VIA   "Via"

Definition at line 289 of file microhttpd.h.

#define MHD_HTTP_HEADER_WARNING   "Warning"

Definition at line 290 of file microhttpd.h.

#define MHD_HTTP_HEADER_WWW_AUTHENTICATE   "WWW-Authenticate"

Definition at line 291 of file microhttpd.h.

#define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED   505

Definition at line 227 of file microhttpd.h.

#define MHD_HTTP_INSUFFICIENT_STORAGE   507

Definition at line 229 of file microhttpd.h.

#define MHD_HTTP_INTERNAL_SERVER_ERROR   500

Definition at line 222 of file microhttpd.h.

#define MHD_HTTP_LENGTH_REQUIRED   411

Definition at line 205 of file microhttpd.h.

#define MHD_HTTP_LOCKED   423

Definition at line 213 of file microhttpd.h.

#define MHD_HTTP_METHOD_CONNECT   "CONNECT"

HTTP methods

Definition at line 303 of file microhttpd.h.

#define MHD_HTTP_METHOD_DELETE   "DELETE"

Definition at line 304 of file microhttpd.h.

#define MHD_HTTP_METHOD_GET   "GET"

Definition at line 305 of file microhttpd.h.

#define MHD_HTTP_METHOD_HEAD   "HEAD"

Definition at line 306 of file microhttpd.h.

#define MHD_HTTP_METHOD_NOT_ACCEPTABLE   406

Definition at line 200 of file microhttpd.h.

#define MHD_HTTP_METHOD_NOT_ALLOWED   405

Definition at line 199 of file microhttpd.h.

#define MHD_HTTP_METHOD_OPTIONS   "OPTIONS"

Definition at line 307 of file microhttpd.h.

#define MHD_HTTP_METHOD_POST   "POST"

Definition at line 308 of file microhttpd.h.

#define MHD_HTTP_METHOD_PUT   "PUT"

Definition at line 309 of file microhttpd.h.

#define MHD_HTTP_METHOD_TRACE   "TRACE"

Definition at line 310 of file microhttpd.h.

#define MHD_HTTP_MOVED_PERMANENTLY   301

Definition at line 186 of file microhttpd.h.

#define MHD_HTTP_MULTI_STATUS   207

Definition at line 183 of file microhttpd.h.

#define MHD_HTTP_MULTIPLE_CHOICES   300

Definition at line 185 of file microhttpd.h.

#define MHD_HTTP_NO_CONTENT   204

Definition at line 180 of file microhttpd.h.

#define MHD_HTTP_NO_RESPONSE   444

Definition at line 217 of file microhttpd.h.

#define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION   203

Definition at line 179 of file microhttpd.h.

#define MHD_HTTP_NOT_EXTENDED   510

Definition at line 231 of file microhttpd.h.

#define MHD_HTTP_NOT_FOUND   404

Definition at line 198 of file microhttpd.h.

#define MHD_HTTP_NOT_IMPLEMENTED   501

Definition at line 223 of file microhttpd.h.

#define MHD_HTTP_NOT_MODIFIED   304

Definition at line 189 of file microhttpd.h.

#define MHD_HTTP_OK   200

Definition at line 176 of file microhttpd.h.

#define MHD_HTTP_PARTIAL_CONTENT   206

Definition at line 182 of file microhttpd.h.

#define MHD_HTTP_PAYMENT_REQUIRED   402

Definition at line 196 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 316 of file microhttpd.h.

#define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA   "multipart/form-data"

Definition at line 317 of file microhttpd.h.

#define MHD_HTTP_PRECONDITION_FAILED   412

Definition at line 206 of file microhttpd.h.

#define MHD_HTTP_PROCESSING   102

Definition at line 174 of file microhttpd.h.

#define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED   407

Definition at line 201 of file microhttpd.h.

#define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE   413

Definition at line 207 of file microhttpd.h.

#define MHD_HTTP_REQUEST_TIMEOUT   408

Definition at line 202 of file microhttpd.h.

#define MHD_HTTP_REQUEST_URI_TOO_LONG   414

Definition at line 208 of file microhttpd.h.

#define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE   416

Definition at line 210 of file microhttpd.h.

#define MHD_HTTP_RESET_CONTENT   205

Definition at line 181 of file microhttpd.h.

#define MHD_HTTP_RETRY_WITH   449

Definition at line 218 of file microhttpd.h.

#define MHD_HTTP_SEE_OTHER   303

Definition at line 188 of file microhttpd.h.

#define MHD_HTTP_SERVICE_UNAVAILABLE   503

Definition at line 225 of file microhttpd.h.

#define MHD_HTTP_SWITCH_PROXY   306

Definition at line 191 of file microhttpd.h.

#define MHD_HTTP_SWITCHING_PROTOCOLS   101

Definition at line 173 of file microhttpd.h.

#define MHD_HTTP_TEMPORARY_REDIRECT   307

Definition at line 192 of file microhttpd.h.

#define MHD_HTTP_UNAUTHORIZED   401

Definition at line 195 of file microhttpd.h.

#define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS   451

Definition at line 220 of file microhttpd.h.

#define MHD_HTTP_UNORDERED_COLLECTION   425

Definition at line 215 of file microhttpd.h.

#define MHD_HTTP_UNPROCESSABLE_ENTITY   422

Definition at line 212 of file microhttpd.h.

#define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE   415

Definition at line 209 of file microhttpd.h.

#define MHD_HTTP_UPGRADE_REQUIRED   426

Definition at line 216 of file microhttpd.h.

#define MHD_HTTP_USE_PROXY   305

Definition at line 190 of file microhttpd.h.

#define MHD_HTTP_VARIANT_ALSO_NEGOTIATES   506

Definition at line 228 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 297 of file microhttpd.h.

#define MHD_HTTP_VERSION_1_1   "HTTP/1.1"

Definition at line 298 of file microhttpd.h.

#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 238 of file microhttpd.h.

#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 1753 of file microhttpd.h.

#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 1753 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 153 of file microhttpd.h.

#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 164 of file microhttpd.h.

#define MHD_NO   0

MHD-internal return code for "NO".

Definition at line 119 of file microhttpd.h.

#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.

#define MHD_UNSIGNED_LONG_LONG   unsigned long long

Definition at line 154 of file microhttpd.h.

#define MHD_UNSIGNED_LONG_LONG_PRINTF   "%llu"

Definition at line 165 of file microhttpd.h.

#define MHD_VERSION   0x00092100

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.

Typedef Documentation

typedef int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)

Allow or deny a client to connect.

Parameters
addraddress information from the client
addrlenlength of the address information
Returns
MHD_YES if connection is allowed, MHD_NO if not

Definition at line 876 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.).

Parameters
clsargument given together with the function pointer when the handler was registered with MHD
urlthe requested url
methodthe HTTP method used ("GET", "PUT", etc.)
versionthe HTTP version string (i.e. "HTTP/1.1")
upload_datathe 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_sizeset initially to the size of the upload_data provided; the method must update this value to the number of bytes NOT processed;
con_clspointer 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.
Returns
MHS_YES if the connection was handled successfully, MHS_NO if the socket must be closed due to a serios error while handling the request

Definition at line 917 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()).

Parameters
clsextra argument to the callback
posposition 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.
bufwhere to copy the data
maxmaximum number of bytes to copy to buf (size of buf)
Returns
number of bytes written to 'buf'; 0 is legal unless we are running in internal select mode (since this would cause busy-waiting); 0 in external select mode will cause this function to be called again once the external select calls MHD again; MHD_CONTENT_READER_END_OF_STREAM (-1) for the regular end of transmission (with chunked encoding, MHD will then terminate the chunk and send any HTTP footers that might be present; without chunked encoding and given an unknown response size, MHD will simply close the connection; note that while returning END_OF_STREAM is not technically legal if a response size was specified, MHD accepts this and treats it just as MHD_CONTENT_READER_END_WITH_ERROR; MHD_CONTENT_READER_END_WITH_ERROR (-2) to indicate a server error generating the response; this will cause MHD to simply close the connection immediately. If a response size was given or if chunked encoding is in use, this will indicate an error to the client. Note, however, that if the client does not know a response size and chunked encoding is not in use, then clients will not be able to tell the difference between MHD_CONTENT_READER_END_WITH_ERROR and MHD_CONTENT_READER_END_OF_STREAM. This is not a limitation of MHD but rather of the HTTP protocol.

Definition at line 1009 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 1022 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.

Returns
MHD_YES to continue iterating, MHD_NO to abort the iteration

Definition at line 956 of file microhttpd.h.

typedef void(* MHD_LogCallback)(void *cls, const char *fm, va_list ap)

Type of a callback function used for logging by MHD.

Parameters
clsclosure
fmformat string (printf-style)
aparguments to 'fm'

Definition at line 407 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().

Parameters
clsuser specified value
filewhere the error occured
linewhere the error occured
reasonerror detail, may be NULL

Definition at line 863 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.

Parameters
clsuser-specified closure
kindtype of the value, always MHD_POSTDATA_KIND when called from MHD
key0-terminated key for the value
filenamename of the uploaded file, NULL if not known
content_typemime-type of the data, NULL if not known
transfer_encodingencoding of the data, NULL if not known
datapointer to size bytes of data at the specified offset
offoffset of data in the overall value
sizenumber of bytes in data available
Returns
MHD_YES to continue iterating, MHD_NO to abort the iteration

Definition at line 1045 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.

Parameters
clsclient-defined closure
connectionconnection handle
con_clsvalue as set by the last call to the MHD_AccessHandlerCallback
toereason for request termination
See Also
MHD_OPTION_NOTIFY_COMPLETED

Definition at line 939 of file microhttpd.h.

Enumeration Type Documentation

MHD connection options. Given to 'MHD_set_connection_option' to set custom options for a particular connection.

Enumerator
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 1895 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 "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 756 of file microhttpd.h.

Values of this enum are used to specify what information about a deamon is desired.

Enumerator
MHD_DAEMON_INFO_KEY_SIZE 

Request information about the key size for a particular cipher algorithm. The cipher algorithm should be passed as an extra argument (of type 'enum MHD_GNUTLS_CipherAlgorithm').

MHD_DAEMON_INFO_MAC_KEY_SIZE 

Request information about the key size for a particular cipher algorithm. The cipher algorithm should be passed as an extra argument (of type 'enum MHD_GNUTLS_HashAlgorithm').

MHD_DAEMON_INFO_LISTEN_FD 

Request the file descriptor for the listening socket. No extra arguments should be passed.

Definition at line 803 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).

Enumerator
MHD_NO_FLAG 

No options selected.

MHD_USE_DEBUG 

Run in debug mode. If this flag is used, the library should print error messages and warnings to stderr.

MHD_USE_SSL 

Run in https mode.

MHD_USE_THREAD_PER_CONNECTION 

Run using one thread per connection.

MHD_USE_SELECT_INTERNALLY 

Run using an internal thread doing SELECT.

MHD_USE_IPv6 

Run using the IPv6 protocol (otherwise, MHD will just support IPv4).

MHD_USE_PEDANTIC_CHECKS 

Be pedantic about the protocol (as opposed to as tolerant as possible). Specifically, at the moment, this flag causes MHD to reject http 1.1 connections without a "Host" header. This is required by the standard, but of course in violation of the "be as liberal as possible in what you accept" norm. It is recommended to turn this ON if you are testing clients against MHD, and OFF in production.

MHD_USE_POLL 

Use poll instead of select. This allows sockets with fd >= FD_SETSIZE.

MHD_SUPPRESS_DATE_NO_CLOCK 

Suppress (automatically) adding the 'Date:' header to HTTP responses. This option should ONLY be used on systems that do not have a clock and that DO provide other mechanisms for cache control. See also RFC 2616, section 14.18 (exception 3).

MHD_USE_NO_LISTEN_SOCKET 

Run without a listen socket. This option only makes sense if 'MHD_add_connection' is to be used exclusively to connect HTTP clients to the HTTP server. This option is incompatible with using a thread pool; if it is used, 'MHD_OPTION_THREAD_POOL_SIZE' is ignored.

Definition at line 329 of file microhttpd.h.

enum MHD_OPTION

MHD options. Passed in the varargs portion of MHD_start_daemon.

Enumerator
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). Default is 32 kb (MHD_POOL_SIZE_DEFAULT). Values above 128k are unlikely to result in much benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.

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)" (also known as MHD_LogCallback) 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 "&ndash;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: struct MHD_OptionItem ops[] = { { MHD_OPTION_CONNECTION_LIMIT, 100, NULL }, { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL }, { MHD_OPTION_END, 0, NULL } }; d = MHD_start_daemon(0, 8080, NULL, NULL, dh, NULL, MHD_OPTION_ARRAY, ops, MHD_OPTION_END); For options that expect a single pointer argument, the second member of the struct MHD_OptionItem is ignored. For options that expect two pointer arguments, the first argument must be cast to 'intptr_t'.

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 413 of file microhttpd.h.

The 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.

Definition at line 712 of file microhttpd.h.

Specification for how MHD should treat the memory buffer given for the response.

Enumerator
MHD_RESPMEM_PERSISTENT 

Buffer is a persistent (static/global) buffer that won't change for at least the lifetime of the response, MHD should just use it, not free it, not copy it, just keep an alias to it.

MHD_RESPMEM_MUST_FREE 

Buffer is heap-allocated with 'malloc' (or equivalent) and should be freed by MHD after processing the response has concluded (response reference counter reaches zero).

MHD_RESPMEM_MUST_COPY 

Buffer is in transient memory, but not on the heap (for example, on the stack or non-malloc allocated) and only valid during the call to 'MHD_create_response_from_buffer'. MHD must make its own private copy of the data for processing.

Definition at line 1396 of file microhttpd.h.

The MHD_ValueKind specifies the source of the key-value pairs in the HTTP protocol.

Enumerator
MHD_RESPONSE_HEADER_KIND 

Response header

MHD_HEADER_KIND 

HTTP header.

MHD_COOKIE_KIND 

Cookies. Note that the original HTTP header containing the cookie(s) will still be available and intact.

MHD_POSTDATA_KIND 

POST data. This is available only if a content encoding supported by MHD is used (currently only URL encoding), and only if the posted content fits within the available memory pool. Note that in that case, the upload data given to the MHD_AccessHandlerCallback will be empty (since it has already been processed).

MHD_GET_ARGUMENT_KIND 

GET (URI) arguments.

MHD_FOOTER_KIND 

HTTP footer (only for http 1.1 chunked encodings).

Definition at line 667 of file microhttpd.h.

Function Documentation

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.

Parameters
daemondaemon that manages the connection
client_socketsocket to manage (MHD will expect to receive an HTTP request from this socket next).
addrIP address of the client
addrlennumber of bytes in addr
Returns
MHD_YES on success, MHD_NO if this daemon could not handle the connection (i.e. malloc failed, etc). The socket will be closed in any case.
int MHD_add_response_footer ( struct MHD_Response *  response,
const char *  footer,
const char *  content 
)

Add a footer line to the response.

Parameters
responseresponse to remove a header from
footerthe footer to delete
contentvalue to delete
Returns
MHD_NO on error (i.e. invalid footer or content format).
int MHD_add_response_header ( struct MHD_Response *  response,
const char *  header,
const char *  content 
)

Add a header line to the response.

Parameters
responseresponse to add a header to
headerthe header to add
contentvalue to add
Returns
MHD_NO on error (i.e. invalid header or content format), or out of memory
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

Parameters
connectionThe MHD connection structure
passworda pointer for the password
Returns
NULL if no username could be found, a pointer to the username if found
struct MHD_PostProcessor* MHD_create_post_processor ( struct MHD_Connection *  connection,
size_t  buffer_size,
MHD_PostDataIterator  iter,
void *  iter_cls 
)
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).

Parameters
connectionthe connection on which the POST is happening (used to determine the POST format)
buffer_sizemaximum 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).
iteriterator to be called with the parsed data, Must NOT be NULL.
iter_clsfirst argument to iter
Returns
NULL on error (out of memory, unsupported encoding), otherwise a PP handle
struct MHD_Response* MHD_create_response_from_buffer ( size_t  size,
void *  buffer,
enum MHD_ResponseMemoryMode  mode 
)
read

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters
sizesize of the data portion of the response
buffersize bytes containing the response's data portion
modeflags for buffer management
Returns
NULL on error (i.e. invalid arguments, out of memory)
struct MHD_Response* MHD_create_response_from_callback ( uint64_t  size,
size_t  block_size,
MHD_ContentReaderCallback  crc,
void *  crc_cls,
MHD_ContentReaderFreeCallback  crfc 
)
read

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters
sizesize of the data portion of the response, MHD_SIZE_UNKNOWN for unknown
block_sizepreferred 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
crccallback to use to obtain response data
crc_clsextra argument to crc
crfccallback to call to free crc_cls resources
Returns
NULL on error (i.e. invalid arguments, out of memory)
struct MHD_Response* MHD_create_response_from_data ( size_t  size,
void *  data,
int  must_free,
int  must_copy 
)
read

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters
sizesize of the data portion of the response
datathe data itself
must_freelibmicrohttpd should free data when done
must_copylibmicrohttpd must make a copy of data right away, the data maybe released anytime after this call returns
Returns
NULL on error (i.e. invalid arguments, out of memory)
struct MHD_Response* MHD_create_response_from_fd ( size_t  size,
int  fd 
)
read

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters
sizesize of the data portion of the response
fdfile descriptor referring to a file on disk with the data; will be closed when response is destroyed; fd should be in 'blocking' mode
Returns
NULL on error (i.e. invalid arguments, out of memory)
struct MHD_Response* MHD_create_response_from_fd_at_offset ( size_t  size,
int  fd,
off_t  offset 
)
read

Create a response object. The response object can be extended with header information and then be used any number of times.

Parameters
sizesize of the data portion of the response
fdfile descriptor referring to a file on disk with the data; will be closed when response is destroyed; fd should be in 'blocking' mode
offsetoffset 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.
Returns
NULL on error (i.e. invalid arguments, out of memory)
int MHD_del_response_header ( struct MHD_Response *  response,
const char *  header,
const char *  content 
)

Delete a header (or footer) line from the response.

Parameters
responseresponse to remove a header from
headerthe header to delete
contentvalue to delete
Returns
MHD_NO on error (no such header known)
int MHD_destroy_post_processor ( struct MHD_PostProcessor *  pp)

Release PostProcessor resources.

Parameters
ppthe PostProcessor to destroy
Returns
MHD_YES if processing completed nicely, MHD_NO if there were spurious characters / formatting problems; it is common to ignore the return value of this function
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.

Parameters
responseresponse to destroy
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

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
usernameThe username needs to be authenticated
passwordThe password used in the authentication
nonce_timeoutThe amount of time for a nonce to be invalid in seconds
Returns
MHD_YES if authenticated, MHD_NO if not, MHD_INVALID_NONCE if nonce is invalid
char* MHD_digest_auth_get_username ( struct MHD_Connection *  connection)

Get the username from the authorization header sent by the client

Parameters
connectionThe MHD connection structure
Returns
NULL if no username could be found, a pointer to the username if found
union MHD_ConnectionInfo* MHD_get_connection_info ( struct MHD_Connection *  connection,
enum MHD_ConnectionInfoType  infoType,
  ... 
)
write

Obtain information about the given connection.

Parameters
connectionwhat connection to get information about
infoTypewhat information is desired?
...depends on infoType
Returns
NULL if this information is not available (or if the infoType is unknown)
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.

Parameters
connectionconnection to get values from
kindtypes of values to iterate over
iteratorcallback to call on each header; maybe NULL (then just count headers)
iterator_clsextra argument to iterator
Returns
number of entries iterated over
union MHD_DaemonInfo* MHD_get_daemon_info ( struct MHD_Daemon *  daemon,
enum MHD_DaemonInfoType  infoType,
  ... 
)
write

Obtain information about the given daemon (not fully implemented!).

Parameters
daemonwhat daemon to get information about
infoTypewhat information is desired?
...depends on infoType
Returns
NULL if this information is not available (or if the infoType is unknown)
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.

Parameters
daemondaemon to get sets from
read_fd_setread set
write_fd_setwrite set
except_fd_setexcept set
max_fdincreased to largest FD added (if larger than existing value); can be NULL
Returns
MHD_YES on success, MHD_NO if this daemon was not started with the right options for this call.
const char* MHD_get_response_header ( struct MHD_Response *  response,
const char *  key 
)

Get a particular header (or footer) from the response.

Parameters
responseresponse to query
keywhich header to get
Returns
NULL if header does not exist
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.

Parameters
responseresponse to query
iteratorcallback to call on each header; maybe NULL (then just count headers)
iterator_clsextra argument to iterator
Returns
number of entries iterated over
int MHD_get_timeout ( struct MHD_Daemon *  daemon,
MHD_UNSIGNED_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".

Parameters
daemondaemon to query for timeout
timeoutset to the timeout (in milliseconds)
Returns
MHD_YES on success, MHD_NO if timeouts are not used (or no connections exist that would necessiate the use of a timeout right now).
const char* MHD_get_version ( void  )

Obtain the version of this library

Returns
static version string, e.g. "0.9.9"
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.

Parameters
connectionconnection to get values from
kindwhat kind of value are we looking for
keythe header to look for, NULL to lookup 'trailing' value without a key
Returns
NULL if no such item was found
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.

Parameters
ppthe post processor
post_datapost_data_len bytes of POST data
post_data_lenlength of post_data
Returns
MHD_YES on success, MHD_NO on error (out-of-memory, iterator aborted, parse error)
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

Parameters
connectionThe MHD connection structure
realmThe realm presented to the client
opaquestring to user for opaque value
responsereply 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_staleMHD_YES if the nonce is invalid to add 'stale=true' to the authentication header
Returns
MHD_YES on success, MHD_NO otherwise
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 The given response object is expected to include the payload for the response; the "WWW-Authenticate" header will be added and the response queued with the 'UNAUTHORIZED' status code.

Parameters
connectionThe MHD connection structure
realmthe realm presented to the client
responseresponse object to modify and queue
Returns
MHD_YES on success, MHD_NO otherwise
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).

Parameters
connectionthe connection identifying the client
status_codeHTTP status code (i.e. 200 for OK)
responseresponse to transmit
Returns
MHD_NO on error (i.e. reply already sent), MHD_YES on success or if message has been queued
int MHD_quiesce_daemon ( struct MHD_Daemon *  daemon)

Stop accepting connections from the listening socket. Allows clients to continue processing, but stops accepting new connections. Note that the caller is responsible for closing the returned socket; however, if MHD is run using threads (anything but external select mode), it must not be closed until AFTER "MHD_stop_daemon" has been called (as it is theoretically possible that an existing thread is still using it).

Parameters
daemondaemon to stop accepting new connections for
Returns
old listen socket on success, -1 if the daemon was already not listening anymore
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.

This function is a convenience method, which is useful if the fd_sets from "MHD_get_fdset" were not directly passed to 'select'; with this function, MHD will internally do the appropriate 'select' call itself again. While it is always safe to call 'MHD_run' (in external select mode), you should call 'MHD_run_from_select' if performance is important (as it saves an expensive call to 'select').

Parameters
daemondaemon to run
Returns
MHD_YES on success, MHD_NO if this daemon was not started with the right options for this call.
int MHD_run_from_select ( struct MHD_Daemon *  daemon,
const fd_set *  read_fd_set,
const fd_set *  write_fd_set,
const fd_set *  except_fd_set 
)

Run webserver operations. This method should be called by clients in combination with MHD_get_fdset if the client-controlled select method is used.

You can use this function instead of "MHD_run" if you called 'select' on the result from "MHD_get_fdset". File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of "MHD_run" is more efficient as MHD will not have to call 'select' again to determine which operations are ready.

Parameters
daemondaemon to run select loop for
read_fd_setread set
write_fd_setwrite set
except_fd_setexcept set (not used, can be NULL)
Returns
MHD_NO on serious errors, MHD_YES on success
int MHD_set_connection_option ( struct MHD_Connection *  connection,
enum MHD_CONNECTION_OPTION  option,
  ... 
)

Set a custom option for the given connection, overriding defaults.

Parameters
connectionconnection to modify
optionoption to set
...arguments to the option, depending on the option type
Returns
MHD_YES on success, MHD_NO if setting the option failed
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.).

Parameters
connectionthe connection for which a value should be set
kindkind of the value
keykey for the value
valuethe value itself
Returns
MHD_NO if the operation could not be performed due to insufficient memory; MHD_YES on success
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.

Parameters
cbnew error handler
clspassed to error handler
struct MHD_Daemon* MHD_start_daemon ( unsigned int  flags,
uint16_t  port,
MHD_AcceptPolicyCallback  apc,
void *  apc_cls,
MHD_AccessHandlerCallback  dh,
void *  dh_cls,
  ... 
)
read

Start a webserver on the given port. Variadic version of MHD_start_daemon_va.

Parameters
flagscombination of MHD_FLAG values
portport to bind to
apccallback 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_clsextra argument to apc
dhhandler called for all requests (repeatedly)
dh_clsextra argument to dh
Returns
NULL on error, handle to daemon on success
struct MHD_Daemon* MHD_start_daemon_va ( unsigned int  flags,
uint16_t  port,
MHD_AcceptPolicyCallback  apc,
void *  apc_cls,
MHD_AccessHandlerCallback  dh,
void *  dh_cls,
va_list  ap 
)
read

Start a webserver on the given port.

Parameters
flagscombination of MHD_FLAG values
portport to bind to
apccallback 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_clsextra argument to apc
dhhandler called for all requests (repeatedly)
dh_clsextra argument to dh
aplist of options (type-value pairs, terminated with MHD_OPTION_END).
Returns
NULL on error, handle to daemon on success
void MHD_stop_daemon ( struct MHD_Daemon *  daemon)

Shutdown an http daemon.

Parameters
daemondaemon to stop