GNU libmicrohttpd  0.9.72
microhttpd.h File Reference

public interface to libmicrohttpd More...

#include <stdarg.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
Include dependency graph for microhttpd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MHD_OptionItem
 
union  MHD_ConnectionInfo
 
union  MHD_DaemonInfo
 

Macros

#define MHD_VERSION   0x00097200
 
#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_EXTERN   extern
 
#define MHD_POSIX_SOCKETS   1
 
#define MHD_INVALID_SOCKET   (-1)
 
#define MHD_SOCKET_DEFINED   1
 
#define _MHD_DEPR_MACRO(msg)
 
#define _MHD_NO_DEPR_IN_MACRO   1
 
#define _MHD_DEPR_IN_MACRO(msg)
 
#define _MHD_NO_DEPR_FUNC   1
 
#define _MHD_DEPR_FUNC(msg)
 
#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_MD5_DIGEST_SIZE   16
 
#define MHD_HTTP_CONTINUE   100
 
#define MHD_HTTP_SWITCHING_PROTOCOLS   101
 
#define MHD_HTTP_PROCESSING   102
 
#define MHD_HTTP_EARLY_HINTS   103
 
#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_ALREADY_REPORTED   208
 
#define MHD_HTTP_IM_USED   226
 
#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_PERMANENT_REDIRECT   308
 
#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_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_PAYLOAD_TOO_LARGE   413
 
#define MHD_HTTP_URI_TOO_LONG   414
 
#define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE   415
 
#define MHD_HTTP_RANGE_NOT_SATISFIABLE   416
 
#define MHD_HTTP_EXPECTATION_FAILED   417
 
#define MHD_HTTP_MISDIRECTED_REQUEST   421
 
#define MHD_HTTP_UNPROCESSABLE_ENTITY   422
 
#define MHD_HTTP_LOCKED   423
 
#define MHD_HTTP_FAILED_DEPENDENCY   424
 
#define MHD_HTTP_TOO_EARLY   425
 
#define MHD_HTTP_UPGRADE_REQUIRED   426
 
#define MHD_HTTP_PRECONDITION_REQUIRED   428
 
#define MHD_HTTP_TOO_MANY_REQUESTS   429
 
#define MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE   431
 
#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_LOOP_DETECTED   508
 
#define MHD_HTTP_NOT_EXTENDED   510
 
#define MHD_HTTP_NETWORK_AUTHENTICATION_REQUIRED   511
 
#define MHD_HTTP_RETRY_WITH   449
 
#define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS   450
 
#define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED   509
 
#define MHD_HTTP_METHOD_NOT_ACCEPTABLE
 
#define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
 
#define MHD_HTTP_REQUEST_URI_TOO_LONG
 
#define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
 
#define MHD_HTTP_UNORDERED_COLLECTION
 
#define MHD_HTTP_NO_RESPONSE
 
#define MHD_ICY_FLAG   ((uint32_t) (((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_CLOSE   "Close"
 
#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_RANGE   "Content-Range"
 
#define MHD_HTTP_HEADER_CONTENT_TYPE   "Content-Type"
 
#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_MIME_VERSION   "MIME-Version"
 
#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_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_WWW_AUTHENTICATE   "WWW-Authenticate"
 
#define MHD_HTTP_HEADER_WARNING   "Warning"
 
#define MHD_HTTP_HEADER_A_IM   "A-IM"
 
#define MHD_HTTP_HEADER_ACCEPT_ADDITIONS   "Accept-Additions"
 
#define MHD_HTTP_HEADER_ACCEPT_CH   "Accept-CH"
 
#define MHD_HTTP_HEADER_ACCEPT_DATETIME   "Accept-Datetime"
 
#define MHD_HTTP_HEADER_ACCEPT_FEATURES   "Accept-Features"
 
#define MHD_HTTP_HEADER_ACCEPT_PATCH   "Accept-Patch"
 
#define MHD_HTTP_HEADER_ACCEPT_POST   "Accept-Post"
 
#define MHD_HTTP_HEADER_ALPN   "ALPN"
 
#define MHD_HTTP_HEADER_ALT_SVC   "Alt-Svc"
 
#define MHD_HTTP_HEADER_ALT_USED   "Alt-Used"
 
#define MHD_HTTP_HEADER_ALTERNATES   "Alternates"
 
#define MHD_HTTP_HEADER_APPLY_TO_REDIRECT_REF   "Apply-To-Redirect-Ref"
 
#define MHD_HTTP_HEADER_AUTHENTICATION_CONTROL   "Authentication-Control"
 
#define MHD_HTTP_HEADER_AUTHENTICATION_INFO   "Authentication-Info"
 
#define MHD_HTTP_HEADER_C_EXT   "C-Ext"
 
#define MHD_HTTP_HEADER_C_MAN   "C-Man"
 
#define MHD_HTTP_HEADER_C_OPT   "C-Opt"
 
#define MHD_HTTP_HEADER_C_PEP   "C-PEP"
 
#define MHD_HTTP_HEADER_C_PEP_INFO   "C-PEP-Info"
 
#define MHD_HTTP_HEADER_CAL_MANAGED_ID   "Cal-Managed-ID"
 
#define MHD_HTTP_HEADER_CALDAV_TIMEZONES   "CalDAV-Timezones"
 
#define MHD_HTTP_HEADER_CDN_LOOP   "CDN-Loop"
 
#define MHD_HTTP_HEADER_CERT_NOT_AFTER   "Cert-Not-After"
 
#define MHD_HTTP_HEADER_CERT_NOT_BEFORE   "Cert-Not-Before"
 
#define MHD_HTTP_HEADER_CONTENT_BASE   "Content-Base"
 
#define MHD_HTTP_HEADER_CONTENT_DISPOSITION   "Content-Disposition"
 
#define MHD_HTTP_HEADER_CONTENT_ID   "Content-ID"
 
#define MHD_HTTP_HEADER_CONTENT_MD5   "Content-MD5"
 
#define MHD_HTTP_HEADER_CONTENT_SCRIPT_TYPE   "Content-Script-Type"
 
#define MHD_HTTP_HEADER_CONTENT_STYLE_TYPE   "Content-Style-Type"
 
#define MHD_HTTP_HEADER_CONTENT_VERSION   "Content-Version"
 
#define MHD_HTTP_HEADER_COOKIE   "Cookie"
 
#define MHD_HTTP_HEADER_COOKIE2   "Cookie2"
 
#define MHD_HTTP_HEADER_DASL   "DASL"
 
#define MHD_HTTP_HEADER_DAV   "DAV"
 
#define MHD_HTTP_HEADER_DEFAULT_STYLE   "Default-Style"
 
#define MHD_HTTP_HEADER_DELTA_BASE   "Delta-Base"
 
#define MHD_HTTP_HEADER_DEPTH   "Depth"
 
#define MHD_HTTP_HEADER_DERIVED_FROM   "Derived-From"
 
#define MHD_HTTP_HEADER_DESTINATION   "Destination"
 
#define MHD_HTTP_HEADER_DIFFERENTIAL_ID   "Differential-ID"
 
#define MHD_HTTP_HEADER_DIGEST   "Digest"
 
#define MHD_HTTP_HEADER_EARLY_DATA   "Early-Data"
 
#define MHD_HTTP_HEADER_EXPECT_CT   "Expect-CT"
 
#define MHD_HTTP_HEADER_EXT   "Ext"
 
#define MHD_HTTP_HEADER_FORWARDED   "Forwarded"
 
#define MHD_HTTP_HEADER_GETPROFILE   "GetProfile"
 
#define MHD_HTTP_HEADER_HOBAREG   "Hobareg"
 
#define MHD_HTTP_HEADER_HTTP2_SETTINGS   "HTTP2-Settings"
 
#define MHD_HTTP_HEADER_IM   "IM"
 
#define MHD_HTTP_HEADER_IF   "If"
 
#define MHD_HTTP_HEADER_IF_SCHEDULE_TAG_MATCH   "If-Schedule-Tag-Match"
 
#define MHD_HTTP_HEADER_INCLUDE_REFERRED_TOKEN_BINDING_ID    "Include-Referred-Token-Binding-ID"
 
#define MHD_HTTP_HEADER_KEEP_ALIVE   "Keep-Alive"
 
#define MHD_HTTP_HEADER_LABEL   "Label"
 
#define MHD_HTTP_HEADER_LINK   "Link"
 
#define MHD_HTTP_HEADER_LOCK_TOKEN   "Lock-Token"
 
#define MHD_HTTP_HEADER_MAN   "Man"
 
#define MHD_HTTP_HEADER_MEMENTO_DATETIME   "Memento-Datetime"
 
#define MHD_HTTP_HEADER_METER   "Meter"
 
#define MHD_HTTP_HEADER_NEGOTIATE   "Negotiate"
 
#define MHD_HTTP_HEADER_ODATA_ENTITYID   "OData-EntityId"
 
#define MHD_HTTP_HEADER_ODATA_ISOLATION   "OData-Isolation"
 
#define MHD_HTTP_HEADER_ODATA_MAXVERSION   "OData-MaxVersion"
 
#define MHD_HTTP_HEADER_ODATA_VERSION   "OData-Version"
 
#define MHD_HTTP_HEADER_OPT   "Opt"
 
#define MHD_HTTP_HEADER_OPTIONAL_WWW_AUTHENTICATE   "Optional-WWW-Authenticate"
 
#define MHD_HTTP_HEADER_ORDERING_TYPE   "Ordering-Type"
 
#define MHD_HTTP_HEADER_ORIGIN   "Origin"
 
#define MHD_HTTP_HEADER_OSCORE   "OSCORE"
 
#define MHD_HTTP_HEADER_OVERWRITE   "Overwrite"
 
#define MHD_HTTP_HEADER_P3P   "P3P"
 
#define MHD_HTTP_HEADER_PEP   "PEP"
 
#define MHD_HTTP_HEADER_PICS_LABEL   "PICS-Label"
 
#define MHD_HTTP_HEADER_PEP_INFO   "Pep-Info"
 
#define MHD_HTTP_HEADER_POSITION   "Position"
 
#define MHD_HTTP_HEADER_PREFER   "Prefer"
 
#define MHD_HTTP_HEADER_PREFERENCE_APPLIED   "Preference-Applied"
 
#define MHD_HTTP_HEADER_PROFILEOBJECT   "ProfileObject"
 
#define MHD_HTTP_HEADER_PROTOCOL   "Protocol"
 
#define MHD_HTTP_HEADER_PROTOCOL_INFO   "Protocol-Info"
 
#define MHD_HTTP_HEADER_PROTOCOL_QUERY   "Protocol-Query"
 
#define MHD_HTTP_HEADER_PROTOCOL_REQUEST   "Protocol-Request"
 
#define MHD_HTTP_HEADER_PROXY_AUTHENTICATION_INFO   "Proxy-Authentication-Info"
 
#define MHD_HTTP_HEADER_PROXY_FEATURES   "Proxy-Features"
 
#define MHD_HTTP_HEADER_PROXY_INSTRUCTION   "Proxy-Instruction"
 
#define MHD_HTTP_HEADER_PUBLIC   "Public"
 
#define MHD_HTTP_HEADER_PUBLIC_KEY_PINS   "Public-Key-Pins"
 
#define MHD_HTTP_HEADER_PUBLIC_KEY_PINS_REPORT_ONLY    "Public-Key-Pins-Report-Only"
 
#define MHD_HTTP_HEADER_REDIRECT_REF   "Redirect-Ref"
 
#define MHD_HTTP_HEADER_REPLAY_NONCE   "Replay-Nonce"
 
#define MHD_HTTP_HEADER_SAFE   "Safe"
 
#define MHD_HTTP_HEADER_SCHEDULE_REPLY   "Schedule-Reply"
 
#define MHD_HTTP_HEADER_SCHEDULE_TAG   "Schedule-Tag"
 
#define MHD_HTTP_HEADER_SEC_TOKEN_BINDING   "Sec-Token-Binding"
 
#define MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT   "Sec-WebSocket-Accept"
 
#define MHD_HTTP_HEADER_SEC_WEBSOCKET_EXTENSIONS   "Sec-WebSocket-Extensions"
 
#define MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY   "Sec-WebSocket-Key"
 
#define MHD_HTTP_HEADER_SEC_WEBSOCKET_PROTOCOL   "Sec-WebSocket-Protocol"
 
#define MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION   "Sec-WebSocket-Version"
 
#define MHD_HTTP_HEADER_SECURITY_SCHEME   "Security-Scheme"
 
#define MHD_HTTP_HEADER_SET_COOKIE   "Set-Cookie"
 
#define MHD_HTTP_HEADER_SET_COOKIE2   "Set-Cookie2"
 
#define MHD_HTTP_HEADER_SETPROFILE   "SetProfile"
 
#define MHD_HTTP_HEADER_SLUG   "SLUG"
 
#define MHD_HTTP_HEADER_SOAPACTION   "SoapAction"
 
#define MHD_HTTP_HEADER_STATUS_URI   "Status-URI"
 
#define MHD_HTTP_HEADER_STRICT_TRANSPORT_SECURITY   "Strict-Transport-Security"
 
#define MHD_HTTP_HEADER_SUNSET   "Sunset"
 
#define MHD_HTTP_HEADER_SURROGATE_CAPABILITY   "Surrogate-Capability"
 
#define MHD_HTTP_HEADER_SURROGATE_CONTROL   "Surrogate-Control"
 
#define MHD_HTTP_HEADER_TCN   "TCN"
 
#define MHD_HTTP_HEADER_TIMEOUT   "Timeout"
 
#define MHD_HTTP_HEADER_TOPIC   "Topic"
 
#define MHD_HTTP_HEADER_TTL   "TTL"
 
#define MHD_HTTP_HEADER_URGENCY   "Urgency"
 
#define MHD_HTTP_HEADER_URI   "URI"
 
#define MHD_HTTP_HEADER_VARIANT_VARY   "Variant-Vary"
 
#define MHD_HTTP_HEADER_WANT_DIGEST   "Want-Digest"
 
#define MHD_HTTP_HEADER_X_CONTENT_TYPE_OPTIONS   "X-Content-Type-Options"
 
#define MHD_HTTP_HEADER_X_FRAME_OPTIONS   "X-Frame-Options"
 
#define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN    "Access-Control-Allow-Origin"
 
#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_METHOD_ACL   "ACL"
 
#define MHD_HTTP_METHOD_BASELINE_CONTROL   "BASELINE-CONTROL"
 
#define MHD_HTTP_METHOD_BIND   "BIND"
 
#define MHD_HTTP_METHOD_CHECKIN   "CHECKIN"
 
#define MHD_HTTP_METHOD_CHECKOUT   "CHECKOUT"
 
#define MHD_HTTP_METHOD_COPY   "COPY"
 
#define MHD_HTTP_METHOD_LABEL   "LABEL"
 
#define MHD_HTTP_METHOD_LINK   "LINK"
 
#define MHD_HTTP_METHOD_LOCK   "LOCK"
 
#define MHD_HTTP_METHOD_MERGE   "MERGE"
 
#define MHD_HTTP_METHOD_MKACTIVITY   "MKACTIVITY"
 
#define MHD_HTTP_METHOD_MKCALENDAR   "MKCALENDAR"
 
#define MHD_HTTP_METHOD_MKCOL   "MKCOL"
 
#define MHD_HTTP_METHOD_MKREDIRECTREF   "MKREDIRECTREF"
 
#define MHD_HTTP_METHOD_MKWORKSPACE   "MKWORKSPACE"
 
#define MHD_HTTP_METHOD_MOVE   "MOVE"
 
#define MHD_HTTP_METHOD_ORDERPATCH   "ORDERPATCH"
 
#define MHD_HTTP_METHOD_PATCH   "PATCH"
 
#define MHD_HTTP_METHOD_PRI   "PRI"
 
#define MHD_HTTP_METHOD_PROPFIND   "PROPFIND"
 
#define MHD_HTTP_METHOD_PROPPATCH   "PROPPATCH"
 
#define MHD_HTTP_METHOD_REBIND   "REBIND"
 
#define MHD_HTTP_METHOD_REPORT   "REPORT"
 
#define MHD_HTTP_METHOD_SEARCH   "SEARCH"
 
#define MHD_HTTP_METHOD_UNBIND   "UNBIND"
 
#define MHD_HTTP_METHOD_UNCHECKOUT   "UNCHECKOUT"
 
#define MHD_HTTP_METHOD_UNLINK   "UNLINK"
 
#define MHD_HTTP_METHOD_UNLOCK   "UNLOCK"
 
#define MHD_HTTP_METHOD_UPDATE   "UPDATE"
 
#define MHD_HTTP_METHOD_UPDATEREDIRECTREF   "UPDATEREDIRECTREF"
 
#define MHD_HTTP_METHOD_VERSION_CONTROL   "VERSION-CONTROL"
 
#define MHD_HTTP_POST_ENCODING_FORM_URLENCODED    "application/x-www-form-urlencoded"
 
#define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA   "multipart/form-data"
 
#define MHD_RESPONSE_HEADER_KIND
 
#define MHD_get_fdset(daemon, read_fd_set, write_fd_set, except_fd_set, max_fd)
 
#define MHD_create_response_from_fd_at_offset(size, fd, offset)
 
#define MHD_INVALID_NONCE   -1
 

Typedefs

typedef int MHD_socket
 
typedef void(* MHD_LogCallback) (void *cls, const char *fm, va_list ap)
 
typedef int(* MHD_PskServerCredentialsCallback) (void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size)
 
typedef void(* MHD_PanicCallback) (void *cls, const char *file, unsigned int line, const char *reason)
 
typedef enum MHD_Result(* MHD_AcceptPolicyCallback) (void *cls, const struct sockaddr *addr, socklen_t addrlen)
 
typedef enum MHD_Result(* 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 void(* MHD_NotifyConnectionCallback) (void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
 
typedef enum MHD_Result(* MHD_KeyValueIterator) (void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
 
typedef enum MHD_Result(* MHD_KeyValueIteratorN) (void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size)
 
typedef ssize_t(* MHD_ContentReaderCallback) (void *cls, uint64_t pos, char *buf, size_t max)
 
typedef void(* MHD_ContentReaderFreeCallback) (void *cls)
 
typedef enum MHD_Result(* 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, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh)
 

Enumerations

enum  MHD_Result { MHD_NO = 0 , MHD_YES = 1 }
 
enum  MHD_FLAG {
  MHD_NO_FLAG = 0 , MHD_USE_ERROR_LOG = 1 , MHD_USE_DEBUG = 1 , MHD_USE_TLS = 2 ,
  MHD_USE_SSL = 2 , MHD_USE_THREAD_PER_CONNECTION = 4 , MHD_USE_INTERNAL_POLLING_THREAD = 8 , MHD_USE_SELECT_INTERNALLY = 8 ,
  MHD_USE_IPv6 = 16 , MHD_USE_PEDANTIC_CHECKS = 32 , MHD_USE_POLL = 64 , MHD_USE_POLL_INTERNAL_THREAD = MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD ,
  MHD_USE_POLL_INTERNALLY = MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD , MHD_USE_SUPPRESS_DATE_NO_CLOCK = 128 , MHD_SUPPRESS_DATE_NO_CLOCK = 128 , MHD_USE_NO_LISTEN_SOCKET = 256 ,
  MHD_USE_EPOLL = 512 , MHD_USE_EPOLL_LINUX_ONLY = 512 , MHD_USE_EPOLL_INTERNAL_THREAD , MHD_USE_EPOLL_INTERNALLY = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD ,
  MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY , MHD_USE_ITC = 1024 , MHD_USE_PIPE_FOR_SHUTDOWN = 1024 , MHD_USE_DUAL_STACK = MHD_USE_IPv6 | 2048 ,
  MHD_USE_TURBO = 4096 , MHD_USE_EPOLL_TURBO = 4096 , MHD_ALLOW_SUSPEND_RESUME = 8192 | MHD_USE_ITC , MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_ITC ,
  MHD_USE_TCP_FASTOPEN = 16384 , MHD_ALLOW_UPGRADE = 32768 , MHD_USE_AUTO = 65536 , MHD_USE_AUTO_INTERNAL_THREAD = MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD ,
  MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT = 1U << 17 , MHD_USE_INSECURE_TLS_EARLY_DATA = 1U << 18
}
 Flags for the struct MHD_Daemon. More...
 
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 , MHD_OPTION_CONNECTION_MEMORY_INCREMENT = 21 , MHD_OPTION_HTTPS_CERT_CALLBACK = 22 , MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE = 23 ,
  MHD_OPTION_HTTPS_MEM_DHPARAMS = 24 , MHD_OPTION_LISTENING_ADDRESS_REUSE = 25 , MHD_OPTION_HTTPS_KEY_PASSWORD = 26 , MHD_OPTION_NOTIFY_CONNECTION = 27 ,
  MHD_OPTION_LISTEN_BACKLOG_SIZE = 28 , MHD_OPTION_STRICT_FOR_CLIENT = 29 , MHD_OPTION_GNUTLS_PSK_CRED_HANDLER = 30 , MHD_OPTION_HTTPS_CERT_CALLBACK2 = 31 ,
  MHD_OPTION_SERVER_INSANITY = 32
}
 MHD options. More...
 
enum  MHD_DisableSanityCheck { MHD_DSC_SANE = 0 }
 
enum  MHD_ValueKind {
  MHD_RESPONSE_HEADER_KIND = 0 , 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 , MHD_REQUEST_TERMINATED_CLIENT_ABORT = 5
}
 
enum  MHD_ConnectionNotificationCode { MHD_CONNECTION_NOTIFY_STARTED = 0 , MHD_CONNECTION_NOTIFY_CLOSED = 1 }
 
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 , MHD_CONNECTION_INFO_CONNECTION_FD , MHD_CONNECTION_INFO_SOCKET_CONTEXT ,
  MHD_CONNECTION_INFO_CONNECTION_SUSPENDED , MHD_CONNECTION_INFO_CONNECTION_TIMEOUT , MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE
}
 
enum  MHD_DaemonInfoType {
  MHD_DAEMON_INFO_KEY_SIZE , MHD_DAEMON_INFO_MAC_KEY_SIZE , MHD_DAEMON_INFO_LISTEN_FD , MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY ,
  MHD_DAEMON_INFO_EPOLL_FD = MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY , MHD_DAEMON_INFO_CURRENT_CONNECTIONS , MHD_DAEMON_INFO_FLAGS , MHD_DAEMON_INFO_BIND_PORT
}
 
enum  MHD_ResponseFlags { MHD_RF_NONE = 0 , MHD_RF_HTTP_VERSION_1_0_ONLY = 1 , MHD_RF_HTTP_VERSION_1_0_RESPONSE = 2 , MHD_RF_INSANITY_HEADER_CONTENT_LENGTH = 4 }
 
enum  MHD_ResponseOptions { MHD_RO_END = 0 }
 
enum  MHD_ResponseMemoryMode { MHD_RESPMEM_PERSISTENT , MHD_RESPMEM_MUST_FREE , MHD_RESPMEM_MUST_COPY }
 
enum  MHD_UpgradeAction { MHD_UPGRADE_ACTION_CLOSE = 0 , MHD_UPGRADE_ACTION_CORK_ON = 1 , MHD_UPGRADE_ACTION_CORK_OFF = 2 }
 
enum  MHD_DigestAuthAlgorithm { MHD_DIGEST_ALG_AUTO = 0 , MHD_DIGEST_ALG_MD5 , MHD_DIGEST_ALG_SHA256 }
 
enum  MHD_CONNECTION_OPTION { MHD_CONNECTION_OPTION_TIMEOUT }
 
enum  MHD_FEATURE {
  MHD_FEATURE_MESSAGES = 1 , MHD_FEATURE_TLS = 2 , MHD_FEATURE_SSL = 2 , MHD_FEATURE_HTTPS_CERT_CALLBACK = 3 ,
  MHD_FEATURE_IPv6 = 4 , MHD_FEATURE_IPv6_ONLY = 5 , MHD_FEATURE_POLL = 6 , MHD_FEATURE_EPOLL = 7 ,
  MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET = 8 , MHD_FEATURE_SOCKETPAIR = 9 , MHD_FEATURE_TCP_FASTOPEN = 10 , MHD_FEATURE_BASIC_AUTH = 11 ,
  MHD_FEATURE_DIGEST_AUTH = 12 , MHD_FEATURE_POSTPROCESSOR = 13 , MHD_FEATURE_HTTPS_KEY_PASSWORD = 14 , MHD_FEATURE_LARGE_FILE = 15 ,
  MHD_FEATURE_THREAD_NAMES = 16 , MHD_THREAD_NAMES = 16 , MHD_FEATURE_UPGRADE = 17 , MHD_FEATURE_RESPONSES_SHARED_FD = 18 ,
  MHD_FEATURE_AUTODETECT_BIND_PORT = 19 , MHD_FEATURE_AUTOSUPPRESS_SIGPIPE = 20 , MHD_FEATURE_SENDFILE = 21 , MHD_FEATURE_THREADS = 22 ,
  MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23
}
 

Functions

_MHD_EXTERN const char * MHD_get_reason_phrase_for (unsigned int code)
 
_MHD_EXTERN struct MHD_DaemonMHD_start_daemon_va (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap)
 
_MHD_EXTERN struct MHD_DaemonMHD_start_daemon (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...)
 
_MHD_EXTERN MHD_socket MHD_quiesce_daemon (struct MHD_Daemon *daemon)
 
_MHD_EXTERN void MHD_stop_daemon (struct MHD_Daemon *daemon)
 
_MHD_EXTERN enum MHD_Result MHD_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
 
_MHD_EXTERN enum MHD_Result MHD_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd)
 
_MHD_EXTERN enum MHD_Result MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize)
 
_MHD_EXTERN enum MHD_Result MHD_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
 
_MHD_EXTERN enum MHD_Result MHD_run (struct MHD_Daemon *daemon)
 
_MHD_EXTERN enum MHD_Result 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)
 
_MHD_EXTERN int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
 
_MHD_EXTERN int MHD_get_connection_values_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls)
 
_MHD_EXTERN enum MHD_Result MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value)
 
_MHD_EXTERN enum MHD_Result MHD_set_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size)
 
_MHD_EXTERN void MHD_set_panic_func (MHD_PanicCallback cb, void *cls)
 
_MHD_EXTERN size_t MHD_http_unescape (char *val)
 
_MHD_EXTERN const char * MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
 
_MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr)
 
_MHD_EXTERN enum MHD_Result MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
 
_MHD_EXTERN void MHD_suspend_connection (struct MHD_Connection *connection)
 
_MHD_EXTERN void MHD_resume_connection (struct MHD_Connection *connection)
 
_MHD_EXTERN enum MHD_Result MHD_set_response_options (struct MHD_Response *response, enum MHD_ResponseFlags flags,...)
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc)
 
 _MHD_DEPR_FUNC ("MHD_create_response_from_data() is deprecated, use MHD_create_response_from_buffer()") _MHD_EXTERN struct MHD_Response *MHD_create_response_from_data(size_t size
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_buffer (size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_buffer_with_free_callback (size_t size, void *buffer, MHD_ContentReaderFreeCallback crfc)
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_fd (size_t size, int fd)
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_pipe (int fd)
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_fd64 (uint64_t size, int fd)
 
 _MHD_DEPR_FUNC ("Function MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") _MHD_EXTERN struct MHD_Response *MHD_create_response_from_fd_at_offset(size_t size
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_from_fd_at_offset64 (uint64_t size, int fd, uint64_t offset)
 
_MHD_EXTERN enum MHD_Result MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeAction action,...)
 
_MHD_EXTERN struct MHD_ResponseMHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls)
 
_MHD_EXTERN void MHD_destroy_response (struct MHD_Response *response)
 
_MHD_EXTERN enum MHD_Result MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content)
 
_MHD_EXTERN enum MHD_Result MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content)
 
_MHD_EXTERN enum MHD_Result MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content)
 
_MHD_EXTERN int MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)
 
_MHD_EXTERN const char * MHD_get_response_header (struct MHD_Response *response, const char *key)
 
_MHD_EXTERN struct MHD_PostProcessor * MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls)
 
_MHD_EXTERN enum MHD_Result MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
 
_MHD_EXTERN enum MHD_Result MHD_destroy_post_processor (struct MHD_PostProcessor *pp)
 
_MHD_EXTERN char * MHD_digest_auth_get_username (struct MHD_Connection *connection)
 
_MHD_EXTERN void MHD_free (void *ptr)
 
_MHD_EXTERN int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout)
 
_MHD_EXTERN int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, size_t digest_size, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale)
 
_MHD_EXTERN char * MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char **password)
 
_MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
 
_MHD_EXTERN const union MHD_ConnectionInfoMHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
 
_MHD_EXTERN enum MHD_Result MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
 
_MHD_EXTERN const union MHD_DaemonInfoMHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type,...)
 
_MHD_EXTERN const char * MHD_get_version (void)
 
_MHD_EXTERN enum MHD_Result MHD_is_feature_supported (enum MHD_FEATURE feature)
 

Variables

void * data
 
void int must_free
 
void int int must_copy
 
int fd
 
int off_t offset
 

Detailed Description

public interface to libmicrohttpd

Author
Christian Grothoff
Karlson2k (Evgeny Grin)
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 "multipart/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).

Definition in file microhttpd.h.

Macro Definition Documentation

◆ _MHD_DEPR_FUNC

#define _MHD_DEPR_FUNC (   msg)

Definition at line 286 of file microhttpd.h.

◆ _MHD_DEPR_IN_MACRO

#define _MHD_DEPR_IN_MACRO (   msg)

Definition at line 260 of file microhttpd.h.

◆ _MHD_DEPR_MACRO

#define _MHD_DEPR_MACRO (   msg)

Define MHD_NO_DEPRECATION before including "microhttpd.h" to disable deprecation messages

Definition at line 255 of file microhttpd.h.

◆ _MHD_EXTERN

#define _MHD_EXTERN   extern

Definition at line 186 of file microhttpd.h.

◆ _MHD_NO_DEPR_FUNC

#define _MHD_NO_DEPR_FUNC   1

Definition at line 285 of file microhttpd.h.

◆ _MHD_NO_DEPR_IN_MACRO

#define _MHD_NO_DEPR_IN_MACRO   1

Definition at line 259 of file microhttpd.h.

◆ MHD_CONTENT_READER_END_OF_STREAM

#define MHD_CONTENT_READER_END_OF_STREAM   ((size_t) -1LL)

Definition at line 175 of file microhttpd.h.

◆ MHD_CONTENT_READER_END_WITH_ERROR

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

Definition at line 176 of file microhttpd.h.

◆ MHD_create_response_from_fd_at_offset

#define MHD_create_response_from_fd_at_offset (   size,
  fd,
  offset 
)
Value:
"Usage of MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \
MHD_create_response_from_fd_at_offset64 ((size),(fd),(offset))
#define _MHD_DEPR_IN_MACRO(msg)
Definition: microhttpd.h:260
int off_t offset
Definition: microhttpd.h:3196
int fd
Definition: microhttpd.h:3195

Definition at line 3201 of file microhttpd.h.

◆ MHD_INVALID_SOCKET

#define MHD_INVALID_SOCKET   (-1)

Definition at line 197 of file microhttpd.h.

◆ MHD_LONG_LONG

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

◆ MHD_LONG_LONG_PRINTF

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

◆ MHD_MD5_DIGEST_SIZE

#define MHD_MD5_DIGEST_SIZE   16

Length of the binary output of the MD5 hash function.

Definition at line 323 of file microhttpd.h.

◆ MHD_POSIX_SOCKETS

#define MHD_POSIX_SOCKETS   1

MHD_socket is type for socket FDs

Definition at line 195 of file microhttpd.h.

◆ MHD_RESPONSE_HEADER_KIND

#define MHD_RESPONSE_HEADER_KIND
Value:
"Value MHD_RESPONSE_HEADER_KIND is deprecated and not used") \
MHD_RESPONSE_HEADER_KIND

Definition at line 1788 of file microhttpd.h.

◆ MHD_SIZE_UNKNOWN

#define MHD_SIZE_UNKNOWN   ((uint64_t) -1LL)

Constant used to indicate unknown size (use when creating a response).

Definition at line 168 of file microhttpd.h.

◆ MHD_SOCKET_DEFINED

#define MHD_SOCKET_DEFINED   1

Definition at line 204 of file microhttpd.h.

◆ MHD_UNSIGNED_LONG_LONG

#define MHD_UNSIGNED_LONG_LONG   unsigned long long

Definition at line 299 of file microhttpd.h.

◆ MHD_UNSIGNED_LONG_LONG_PRINTF

#define MHD_UNSIGNED_LONG_LONG_PRINTF   "%llu"

Definition at line 313 of file microhttpd.h.

◆ MHD_VERSION

#define MHD_VERSION   0x00097200

Current version of the library.

Note
While it is a hexadecimal number, it is parsed as decimal number. Example: 0x01093001 = 1.9.30-1.

Definition at line 136 of file microhttpd.h.

Typedef Documentation

◆ MHD_AcceptPolicyCallback

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

Allow or deny a client to connect.

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

Definition at line 2130 of file microhttpd.h.

◆ MHD_AccessHandlerCallback

typedef enum MHD_Result(* 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 (MHD_HTTP_METHOD_GET, MHD_HTTP_METHOD_PUT, MHD_HTTP_METHOD_DELETE, MHD_HTTP_METHOD_POST, etc). The callback must call MHD callbacks to provide content to give back to the client and return an HTTP status code (i.e. MHD_HTTP_OK, MHD_HTTP_NOT_FOUND, etc.).

Parameters
clsargument given together with the function pointer when the handler was registered with MHD
urlthe requested url
methodthe HTTP method used (MHD_HTTP_METHOD_GET, MHD_HTTP_METHOD_PUT, etc.)
versionthe HTTP version string (i.e. MHD_HTTP_VERSION_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)
[in,out]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;
[in,out]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_RequestCompletedCallback (which can be set with the MHD_OPTION_NOTIFY_COMPLETED). Initially, *con_cls will be NULL.
Returns
MHD_YES if the connection was handled successfully, MHD_NO if the socket must be closed due to a serious error while handling the request

Definition at line 2130 of file microhttpd.h.

◆ MHD_ContentReaderCallback

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. Thus, returning zero should only be used in conjunction with MHD_suspend_connection() to avoid busy waiting.

Parameters
clsextra argument to the callback
posposition in the datastream to access; note that if a struct 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 a struct 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 MHD_CONTENT_READER_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 2338 of file microhttpd.h.

◆ MHD_PostDataIterator

typedef enum MHD_Result(* 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 2354 of file microhttpd.h.

◆ MHD_PskServerCredentialsCallback

typedef int(* MHD_PskServerCredentialsCallback) (void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size)

Function called to lookup the pre shared key (psk) for a given HTTP connection based on the username.

Parameters
clsclosure
connectionthe HTTPS connection
usernamethe user name claimed by the other side
[out]pskto be set to the pre-shared-key; should be allocated with malloc(), will be freed by MHD
[out]psk_sizeto be set to the number of bytes in psk
Returns
0 on success, -1 on errors

Definition at line 1369 of file microhttpd.h.

◆ MHD_socket

typedef int MHD_socket

Definition at line 196 of file microhttpd.h.

◆ MHD_UpgradeHandler

typedef void(* MHD_UpgradeHandler) (void *cls, struct MHD_Connection *connection, void *con_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh)

Function called after a protocol "upgrade" response was sent successfully and the socket should now be controlled by some protocol other than HTTP.

Any data already received on the socket will be made available in extra_in. This can happen if the application sent extra data before MHD send the upgrade response. The application should treat data from extra_in as if it had read it from the socket.

Note that the application must not close() sock directly, but instead use MHD_upgrade_action() for special operations on sock.

Data forwarding to "upgraded" sock will be started as soon as this function return.

Except when in 'thread-per-connection' mode, implementations of this function should never block (as it will still be called from within the main event loop).

Parameters
clsclosure, whatever was given to MHD_create_response_for_upgrade().
connectionoriginal HTTP connection handle, giving the function a last chance to inspect the original HTTP request
con_clslast value left in con_cls of the MHD_AccessHandlerCallback
extra_inif we happened to have read bytes after the HTTP header already (because the client sent more than the HTTP header of the request before we sent the upgrade response), these are the extra bytes already read from sock by MHD. The application should treat these as if it had read them from sock.
extra_in_sizenumber of bytes in extra_in
socksocket to use for bi-directional communication with the client. For HTTPS, this may not be a socket that is directly connected to the client and thus certain operations (TCP-specific setsockopt(), getsockopt(), etc.) may not work as expected (as the socket could be from a socketpair() or a TCP-loopback). The application is expected to perform read()/recv() and write()/send() calls on the socket. The application may also call shutdown(), but must not call close() directly.
urhargument for MHD_upgrade_action()s on this connection. Applications must eventually use this callback to (indirectly) perform the close() action on the sock.

Definition at line 3332 of file microhttpd.h.

Enumeration Type Documentation

◆ MHD_CONNECTION_OPTION

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. If timeout was set to zero (or unset) before, setup of new value by MHD_set_connection_option() will reset timeout timer.

Definition at line 3793 of file microhttpd.h.

◆ MHD_DaemonInfoType

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

Enumerator
MHD_DAEMON_INFO_KEY_SIZE 

No longer supported (will return NULL).

MHD_DAEMON_INFO_MAC_KEY_SIZE 

No longer supported (will return NULL).

MHD_DAEMON_INFO_LISTEN_FD 

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

MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY 

Request the file descriptor for the external epoll. No extra arguments should be passed. Waiting on epoll FD must not block longer than value returned by MHD_get_timeout().

MHD_DAEMON_INFO_EPOLL_FD 
MHD_DAEMON_INFO_CURRENT_CONNECTIONS 

Request the number of current connections handled by the daemon. No extra arguments should be passed. Note: when using MHD in external polling mode, this type of request could be used only when MHD_run()/MHD_run_from_select is not working in other thread at the same time.

MHD_DAEMON_INFO_FLAGS 

Request the daemon flags. No extra arguments should be passed. Note: flags may differ from original 'flags' specified for daemon, especially if MHD_USE_AUTO was set.

MHD_DAEMON_INFO_BIND_PORT 

Request the port number of daemon's listen socket. No extra arguments should be passed. Note: if port '0' was specified for MHD_start_daemon(), returned value will be real port number.

Definition at line 2066 of file microhttpd.h.

◆ MHD_DigestAuthAlgorithm

Which digest algorithm should MHD use for HTTP digest authentication?

Enumerator
MHD_DIGEST_ALG_AUTO 

MHD should pick (currently defaults to SHA-256).

MHD_DIGEST_ALG_MD5 

Force use of MD5.

MHD_DIGEST_ALG_SHA256 

Force use of SHA-256.

Definition at line 3567 of file microhttpd.h.

◆ MHD_DisableSanityCheck

Bitfield for the MHD_OPTION_SERVER_INSANITY specifying which santiy checks should be disabled.

Enumerator
MHD_DSC_SANE 

All sanity checks are enabled.

Definition at line 1739 of file microhttpd.h.

◆ MHD_FEATURE

Types of information about MHD features, used by MHD_is_feature_supported().

Enumerator
MHD_FEATURE_MESSAGES 

Get whether messages are supported. If supported then in debug mode messages can be printed to stderr or to external logger.

MHD_FEATURE_TLS 

Get whether HTTPS is supported. If supported then flag MHD_USE_TLS and options MHD_OPTION_HTTPS_MEM_KEY, MHD_OPTION_HTTPS_MEM_CERT, MHD_OPTION_HTTPS_MEM_TRUST, MHD_OPTION_HTTPS_MEM_DHPARAMS, MHD_OPTION_HTTPS_CRED_TYPE, MHD_OPTION_HTTPS_PRIORITIES can be used.

MHD_FEATURE_SSL 
MHD_FEATURE_HTTPS_CERT_CALLBACK 

Get whether option MHD_OPTION_HTTPS_CERT_CALLBACK is supported.

MHD_FEATURE_IPv6 

Get whether IPv6 is supported. If supported then flag MHD_USE_IPv6 can be used.

MHD_FEATURE_IPv6_ONLY 

Get whether IPv6 without IPv4 is supported. If not supported then IPv4 is always enabled in IPv6 sockets and flag MHD_USE_DUAL_STACK if always used when MHD_USE_IPv6 is specified.

MHD_FEATURE_POLL 

Get whether poll() is supported. If supported then flag MHD_USE_POLL can be used.

MHD_FEATURE_EPOLL 

Get whether epoll() is supported. If supported then Flags MHD_USE_EPOLL and MHD_USE_EPOLL_INTERNAL_THREAD can be used.

MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET 

Get whether shutdown on listen socket to signal other threads is supported. If not supported flag MHD_USE_ITC is automatically forced.

MHD_FEATURE_SOCKETPAIR 

Get whether socketpair is used internally instead of pipe to signal other threads.

MHD_FEATURE_TCP_FASTOPEN 

Get whether TCP Fast Open is supported. If supported then flag MHD_USE_TCP_FASTOPEN and option MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE can be used.

MHD_FEATURE_BASIC_AUTH 

Get whether HTTP Basic authorization is supported. If supported then functions MHD_basic_auth_get_username_password and MHD_queue_basic_auth_fail_response can be used.

MHD_FEATURE_DIGEST_AUTH 

Get whether HTTP Digest authorization is supported. If supported then options MHD_OPTION_DIGEST_AUTH_RANDOM, MHD_OPTION_NONCE_NC_SIZE and MHD_digest_auth_check() can be used.

MHD_FEATURE_POSTPROCESSOR 

Get whether postprocessor is supported. If supported then functions MHD_create_post_processor(), MHD_post_process() and MHD_destroy_post_processor() can be used.

MHD_FEATURE_HTTPS_KEY_PASSWORD 

Get whether password encrypted private key for HTTPS daemon is supported. If supported then option MHD_OPTION_HTTPS_KEY_PASSWORD can be used.

MHD_FEATURE_LARGE_FILE 

Get whether reading files beyond 2 GiB boundary is supported. If supported then MHD_create_response_from_fd(), MHD_create_response_from_fd64 MHD_create_response_from_fd_at_offset() and MHD_create_response_from_fd_at_offset64() can be used with sizes and offsets larger than 2 GiB. If not supported value of size+offset is limited to 2 GiB.

MHD_FEATURE_THREAD_NAMES 

Get whether MHD set names on generated threads.

MHD_THREAD_NAMES 
MHD_FEATURE_UPGRADE 

Get whether HTTP "Upgrade" is supported. If supported then MHD_ALLOW_UPGRADE, MHD_upgrade_action() and MHD_create_response_for_upgrade() can be used.

MHD_FEATURE_RESPONSES_SHARED_FD 

Get whether it's safe to use same FD for multiple calls of MHD_create_response_from_fd() and whether it's safe to use single response generated by MHD_create_response_from_fd() with multiple connections at same time. If MHD_is_feature_supported() return MHD_NO for this feature then usage of responses with same file FD in multiple parallel threads may results in incorrect data sent to remote client. It's always safe to use same file FD in multiple responses if MHD is run in any single thread mode.

MHD_FEATURE_AUTODETECT_BIND_PORT 

Get whether MHD support automatic detection of bind port number.

See also
MHD_DAEMON_INFO_BIND_PORT
MHD_FEATURE_AUTOSUPPRESS_SIGPIPE 

Get whether MHD support SIGPIPE suppression. If SIGPIPE suppression is not supported, application must handle SIGPIPE signal by itself.

MHD_FEATURE_SENDFILE 

Get whether MHD use system's sendfile() function to send file-FD based responses over non-TLS connections.

Note
Since v0.9.56
MHD_FEATURE_THREADS 

Get whether MHD supports threads.

MHD_FEATURE_HTTPS_CERT_CALLBACK2 

Get whether option MHD_OPTION_HTTPS_CERT_CALLBACK2 is supported.

Definition at line 3901 of file microhttpd.h.

◆ MHD_FLAG

enum MHD_FLAG

Flags for the struct MHD_Daemon.

Note that MHD will run automatically in background thread(s) only if MHD_USE_INTERNAL_POLLING_THREAD is used. Otherwise caller (application) must use MHD_run() or MHD_run_from_select() to have MHD processed network connections and data.

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 TLS, epoll or IPv6).

Enumerator
MHD_NO_FLAG 

No options selected.

MHD_USE_ERROR_LOG 

Print errors messages to custom error logger or to stderr if custom error logger is not set.

See also
MHD_OPTION_EXTERNAL_LOGGER
MHD_USE_DEBUG 

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

MHD_USE_TLS 

Run in HTTPS mode. The modern protocol is called TLS.

MHD_USE_SSL 
MHD_USE_THREAD_PER_CONNECTION 

Run using one thread per connection. Must be used only with MHD_USE_INTERNAL_POLLING_THREAD.

MHD_USE_INTERNAL_POLLING_THREAD 

Run using an internal thread (or thread pool) for sockets sending and receiving and data processing. Without this flag MHD will not run automatically in background thread(s). If this flag is set, MHD_run() and MHD_run_from_select() couldn't be used. This flag is set explicitly by MHD_USE_POLL_INTERNAL_THREAD and by MHD_USE_EPOLL_INTERNAL_THREAD.

MHD_USE_SELECT_INTERNALLY 
MHD_USE_IPv6 

Run using the IPv6 protocol (otherwise, MHD will just support IPv4). If you want MHD to support IPv4 and IPv6 using a single socket, pass MHD_USE_DUAL_STACK, otherwise, if you only pass this option, MHD will try to bind to IPv6-only (resulting in no IPv4 support).

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. This option is not compatible with using an 'external' polling mode (as there is no API to get the file descriptors for the external poll() from MHD) and must also not be used in combination with MHD_USE_EPOLL.

See also
MHD_FEATURE_POLL, MHD_USE_POLL_INTERNAL_THREAD
MHD_USE_POLL_INTERNAL_THREAD 

Run using an internal thread (or thread pool) doing poll().

See also
MHD_FEATURE_POLL, MHD_USE_POLL, MHD_USE_INTERNAL_POLLING_THREAD
MHD_USE_POLL_INTERNALLY 
MHD_USE_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_SUPPRESS_DATE_NO_CLOCK 
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.

MHD_USE_EPOLL 

Use epoll() instead of select() or poll() for the event loop. This option is only available on some systems; using the option on systems without epoll will cause MHD_start_daemon to fail. Using this option is not supported with MHD_USE_THREAD_PER_CONNECTION.

See also
MHD_FEATURE_EPOLL
MHD_USE_EPOLL_LINUX_ONLY 
MHD_USE_EPOLL_INTERNAL_THREAD 

Run using an internal thread (or thread pool) doing epoll(). This option is only available on certain platforms; using the option on platform without epoll support will cause MHD_start_daemon to fail.

See also
MHD_FEATURE_EPOLL, MHD_USE_EPOLL, MHD_USE_INTERNAL_POLLING_THREAD
MHD_USE_EPOLL_INTERNALLY 
MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY 
MHD_USE_ITC 

Use inter-thread communication channel. MHD_USE_ITC can be used with MHD_USE_INTERNAL_POLLING_THREAD and is ignored with any "external" mode. It's required for use of MHD_quiesce_daemon or MHD_add_connection. This option is enforced by MHD_ALLOW_SUSPEND_RESUME or MHD_USE_NO_LISTEN_SOCKET. MHD_USE_ITC is always used automatically on platforms where select()/poll()/other ignore shutdown of listen socket.

MHD_USE_PIPE_FOR_SHUTDOWN 
MHD_USE_DUAL_STACK 

Use a single socket for IPv4 and IPv6.

MHD_USE_TURBO 

Enable turbo. Disables certain calls to shutdown(), enables aggressive non-blocking optimistic reads and other potentially unsafe optimizations. Most effects only happen with MHD_USE_EPOLL.

MHD_USE_EPOLL_TURBO 
MHD_ALLOW_SUSPEND_RESUME 

Enable suspend/resume functions, which also implies setting up ITC to signal resume.

MHD_USE_SUSPEND_RESUME 
MHD_USE_TCP_FASTOPEN 

Enable TCP_FASTOPEN option. This option is only available on Linux with a kernel >= 3.6. On other systems, using this option cases MHD_start_daemon to fail.

MHD_ALLOW_UPGRADE 

You need to set this option if you want to use HTTP "Upgrade". "Upgrade" may require usage of additional internal resources, which we do not want to use unless necessary.

MHD_USE_AUTO 

Automatically use best available polling function. Choice of polling function is also depend on other daemon options. If MHD_USE_INTERNAL_POLLING_THREAD is specified then epoll, poll() or select() will be used (listed in decreasing preference order, first function available on system will be used). If MHD_USE_THREAD_PER_CONNECTION is specified then poll() or select() will be used. If those flags are not specified then epoll or select() will be used (as the only suitable for MHD_get_fdset())

MHD_USE_AUTO_INTERNAL_THREAD 

Run using an internal thread (or thread pool) with best available on system polling function. This is combination of MHD_USE_AUTO and MHD_USE_INTERNAL_POLLING_THREAD flags.

MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT 

Flag set to enable post-handshake client authentication (only useful in combination with MHD_USE_TLS).

MHD_USE_INSECURE_TLS_EARLY_DATA 

Flag set to enable TLS 1.3 early data. This has security implications, be VERY careful when using this.

Definition at line 1052 of file microhttpd.h.

◆ MHD_OPTION

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 struct 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, struct MHD_Connection *con)

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.

Note that during the time of this call, most of the connection's state is not initialized (as we have not yet parsed the headers). However, information about the connecting client (IP, socket) is available.

The specified function is called only once per request, therefore some programmers may use it to instantiate their own request objects, freeing them in the notifier MHD_OPTION_NOTIFY_COMPLETED.

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 a 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 a 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 MHD_socket 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 MHD_LogCallback and the second a pointer void * which will be passed as the first argument to the log callback.

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 mode must be MHD_USE_INTERNAL_POLLING_THREAD if thread pooling is enabled (MHD_start_daemon returns NULL for an unsupported thread mode).

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 struct 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 the length of the value left in "s" (without the 0-terminator) and "s" should be updated. Note that the unescape function must not lengthen "s" (the result must be shorter than the input and must still be 0-terminated). However, it may also include binary zeros before the 0-termination. "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 daemon 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 an 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 authentication. This option should be followed by a const char * argument.

MHD_OPTION_CONNECTION_MEMORY_INCREMENT 

Increment to use for growing the read buffer (followed by a size_t). Must fit within MHD_OPTION_CONNECTION_MEMORY_LIMIT.

MHD_OPTION_HTTPS_CERT_CALLBACK 

Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option should be followed by a argument of type gnutls_certificate_retrieve_function2 *. This option provides an alternative to MHD_OPTION_HTTPS_MEM_KEY, MHD_OPTION_HTTPS_MEM_CERT. You must use this version if multiple domains are to be hosted at the same IP address using TLS's Server Name Indication (SNI) extension. In this case, the callback is expected to select the correct certificate based on the SNI information provided. The callback is expected to access the SNI data using gnutls_server_name_get(). Using this option requires GnuTLS 3.0 or higher.

MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE 

When using MHD_USE_TCP_FASTOPEN, this option changes the default TCP fastopen queue length of 50. Note that having a larger queue size can cause resource exhaustion attack as the TCP stack has to now allocate resources for the SYN packet along with its DATA. This option should be followed by an unsigned int argument.

MHD_OPTION_HTTPS_MEM_DHPARAMS 

Memory pointer for the Diffie-Hellman parameters (dh.pem) to be used by the HTTPS daemon for key exchange. This option must be followed by a const char * argument.

MHD_OPTION_LISTENING_ADDRESS_REUSE 

If present and set to true, allow reusing address:port socket (by using SO_REUSEPORT on most platform, or platform-specific ways). If present and set to false, disallow reusing address:port socket (does nothing on most platform, but uses SO_EXCLUSIVEADDRUSE on Windows). This option must be followed by a unsigned int argument.

MHD_OPTION_HTTPS_KEY_PASSWORD 

Memory pointer for a password that decrypts the private key (key.pem) to be used by the HTTPS daemon. This option should be followed by a const char * argument. This should be used in conjunction with MHD_OPTION_HTTPS_MEM_KEY.

See also
MHD_FEATURE_HTTPS_KEY_PASSWORD
MHD_OPTION_NOTIFY_CONNECTION 

Register a function that should be called whenever a connection is started or closed.

This option should be followed by TWO pointers. First a pointer to a function of type MHD_NotifyConnectionCallback and second a pointer to a closure to pass to the request completed callback. The second pointer maybe NULL.

MHD_OPTION_LISTEN_BACKLOG_SIZE 

Allow to change maximum length of the queue of pending connections on listen socket. If not present than default platform-specific SOMAXCONN value is used. This option should be followed by an unsigned int argument.

MHD_OPTION_STRICT_FOR_CLIENT 

If set to 1 - be strict about the protocol. Use -1 to be as tolerant as possible.

Specifically, at the moment, at 1 this flag causes MHD to reject HTTP 1.1 connections without a "Host" header, and to disallow spaces in the URL or (at -1) in HTTP header key strings.

These are required by some versions of the standard, but of course in violation of the "be as liberal as possible in what you accept" norm. It is recommended to set this to 1 if you are testing clients against MHD, and 0 in production. This option should be followed by an int argument.

MHD_OPTION_GNUTLS_PSK_CRED_HANDLER 

This should be a pointer to callback of type gnutls_psk_server_credentials_function that will be given to gnutls_psk_set_server_credentials_function. It is used to retrieve the shared key for a given username.

MHD_OPTION_HTTPS_CERT_CALLBACK2 

Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option should be followed by a argument of type gnutls_certificate_retrieve_function3 *. This option provides an alternative/extension to MHD_OPTION_HTTPS_CERT_CALLBACK. You must use this version if you want to use OCSP stapling. Using this option requires GnuTLS 3.6.3 or higher.

MHD_OPTION_SERVER_INSANITY 

Allows the application to disable certain sanity precautions in MHD. With these, the client can break the HTTP protocol, so this should never be used in production. The options are, however, useful for testing HTTP clients against "broken" server implementations. This argument must be followed by an "unsigned int", corresponding to an enum MHD_DisableSanityCheck.

Definition at line 1381 of file microhttpd.h.

◆ MHD_ResponseFlags

Flags for special handling of responses.

Enumerator
MHD_RF_NONE 

Default: no special flags.

MHD_RF_HTTP_VERSION_1_0_ONLY 

Only respond in conservative HTTP 1.0-mode. In particular, do not (automatically) sent "Connection" headers and always close the connection after generating the response. By default, MHD will respond using the same HTTP version which was set in the request. You can also set the MHD_RF_HTTP_VERSION_1_0_RESPONSE flag to force version 1.0 in the response.

MHD_RF_HTTP_VERSION_1_0_RESPONSE 

Only respond in HTTP 1.0-mode. Contrary to the MHD_RF_HTTP_VERSION_1_0_ONLY flag, the response's HTTP version will always be set to 1.0 and "Connection" headers are still supported.

MHD_RF_INSANITY_HEADER_CONTENT_LENGTH 

Disable sanity check preventing clients from manually setting the HTTP content length option.

Definition at line 2951 of file microhttpd.h.

◆ MHD_ResponseOptions

MHD options (for future extensions).

Enumerator
MHD_RO_END 

End of the list of options.

Definition at line 2989 of file microhttpd.h.

◆ MHD_Result

enum MHD_Result

Operational results from MHD calls.

Enumerator
MHD_NO 

MHD result code for "NO".

MHD_YES 

MHD result code for "YES".

Definition at line 141 of file microhttpd.h.

◆ MHD_UpgradeAction

Enumeration for actions MHD should perform on the underlying socket of the upgrade. This API is not finalized, and in particular the final set of actions is yet to be decided. This is just an idea for what we might want.

Enumerator
MHD_UPGRADE_ACTION_CLOSE 

Close the socket, the application is done with it.

Takes no extra arguments.

MHD_UPGRADE_ACTION_CORK_ON 

Enable CORKing on the underlying socket.

MHD_UPGRADE_ACTION_CORK_OFF 

Disable CORKing on the underlying socket.

Definition at line 3236 of file microhttpd.h.

◆ MHD_ValueKind

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

Enumerator
MHD_RESPONSE_HEADER_KIND 

Response header

MHD_RESPONSE_HEADER_KIND 

Response header

MHD_HEADER_KIND 

HTTP header (request/response).

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

Function Documentation

◆ MHD_create_response_for_upgrade()

_MHD_EXTERN struct MHD_Response* MHD_create_response_for_upgrade ( MHD_UpgradeHandler  upgrade_handler,
void *  upgrade_handler_cls 
)

Create a response object that can be used for 101 UPGRADE responses, for example to implement WebSockets. After sending the response, control over the data stream is given to the callback (which can then, for example, start some bi-directional communication). If the response is queued for multiple connections, the callback will be called for each connection. The callback will ONLY be called after the response header was successfully passed to the OS; if there are communication errors before, the usual MHD connection error handling code will be performed.

Setting the correct HTTP code (i.e. MHD_HTTP_SWITCHING_PROTOCOLS) and setting correct HTTP headers for the upgrade must be done manually (this way, it is possible to implement most existing WebSocket versions using this API; in fact, this API might be useful for any protocol switch, not just WebSockets). Note that draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this way as the header "HTTP/1.1 101 WebSocket Protocol Handshake" cannot be generated; instead, MHD will always produce "HTTP/1.1 101 Switching Protocols" (if the response code 101 is used).

As usual, the response object can be extended with header information and then be used any number of times (as long as the header information is not connection-specific).

Parameters
upgrade_handlerfunction to call with the "upgraded" socket
upgrade_handler_clsclosure for upgrade_handler
Returns
NULL on error (i.e. invalid arguments, out of memory)

◆ MHD_free()

_MHD_EXTERN void MHD_free ( void *  ptr)

Free the memory given by ptr. Calls "free(ptr)". This function should be used to free the username returned by MHD_digest_auth_get_username().

Note
Since v0.9.56
Parameters
ptrpointer to free.

Definition at line 89 of file memorypool.c.

◆ MHD_get_reason_phrase_for()

_MHD_EXTERN const char* MHD_get_reason_phrase_for ( unsigned int  code)

Returns the string reason phrase for a response code.

If message string is not available for a status code, "Unknown" string will be returned.

Definition at line 177 of file reason_phrase.c.

References reasons.

Referenced by build_header_response().

Here is the caller graph for this function:

◆ MHD_http_unescape()

_MHD_EXTERN size_t MHD_http_unescape ( char *  val)

Process escape sequences ('HH') Updates val in place; the result should be UTF-8 encoded and cannot be larger than the input. The result must also still be 0-terminated.

Parameters
valvalue to unescape (modified in the process)
Returns
length of the resulting val (strlen(val) may be shorter afterwards due to elimination of escape sequences)

Process escape sequences ('HH') Updates val in place; the result should be UTF-8 encoded and cannot be larger than the input. The result must also still be 0-terminated.

Parameters
valvalue to unescape (modified in the process)
Returns
length of the resulting val (strlen(val) maybe shorter afterwards due to elimination of escape sequences)

Definition at line 142 of file internal.c.

References MHD_strx_to_uint32_n_().

Referenced by post_process_urlencoded(), process_value(), and unescape_wrapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_resume_connection()

_MHD_EXTERN void MHD_resume_connection ( struct MHD_Connection connection)

Resume handling of network data for suspended connection. It is safe to resume a suspended connection at any time. Calling this function on a connection that was not previously suspended will result in undefined behavior.

If you are using this function in `‘external’' select mode, you must make sure to run MHD_run() and MHD_get_timeout() afterwards (before again calling MHD_get_fdset()), as otherwise the change may not be reflected in the set returned by MHD_get_fdset() and you may end up with a connection that is stuck until the next network activity.

Parameters
connectionthe connection to resume

Resume handling of network data for suspended connection. It is safe to resume a suspended connection at any time. Calling this function on a connection that was not previously suspended will result in undefined behavior.

Parameters
connectionthe connection to resume

Definition at line 3134 of file daemon.c.

Referenced by close_all_connections().

Here is the caller graph for this function:

◆ MHD_set_response_options()

_MHD_EXTERN enum MHD_Result MHD_set_response_options ( struct MHD_Response response,
enum MHD_ResponseFlags  flags,
  ... 
)

Set special flags and options for a response.

Parameters
responsethe response to modify
flagsto set for the response
...MHD_RO_END terminated list of options
Returns
MHD_YES on success, MHD_NO on error

Definition at line 375 of file response.c.

◆ MHD_suspend_connection()

_MHD_EXTERN void MHD_suspend_connection ( struct MHD_Connection connection)

Suspend handling of network data for a given connection. This can be used to dequeue a connection from MHD's event loop for a while.

If you use this API in conjunction with a internal select or a thread pool, you must set the option MHD_USE_ITC to ensure that a resumed connection is immediately processed by MHD.

Suspended connections continue to count against the total number of connections allowed (per daemon, as well as per IP, if such limits are set). Suspended connections will NOT time out; timeouts will restart when the connection handling is resumed. While a connection is suspended, MHD will not detect disconnects by the client.

The only safe time to suspend a connection is from the MHD_AccessHandlerCallback.

Finally, it is an API violation to call MHD_stop_daemon while having suspended connections (this will at least create memory and socket leaks or lead to undefined behavior). You must explicitly resume all connections before stopping the daemon.

Parameters
connectionthe connection to suspend

Suspend handling of network data for a given connection. This can be used to dequeue a connection from MHD's event loop (external select, internal select or thread pool; not applicable to thread-per-connection!) for a while.

If you use this API in conjunction with a internal select or a thread pool, you must set the option MHD_USE_ITC to ensure that a resumed connection is immediately processed by MHD.

Suspended connections continue to count against the total number of connections allowed (per daemon, as well as per IP, if such limits are set). Suspended connections will NOT time out; timeouts will restart when the connection handling is resumed. While a connection is suspended, MHD will not detect disconnects by the client.

The only safe time to suspend a connection is from the MHD_AccessHandlerCallback.

Finally, it is an API violation to call MHD_stop_daemon while having suspended connections (this will at least create memory and socket leaks or lead to undefined behavior). You must explicitly resume all connections before stopping the daemon.

Remarks
In thread-per-connection mode: can be called from any thread, in any other mode: to be called only from thread that process daemon's select()/poll()/etc.
Parameters
connectionthe connection to suspend

Definition at line 3097 of file daemon.c.

References _, MHD_Connection::daemon, internal_suspend_connection_(), mhd_assert, MHD_PANIC, MHD_TEST_ALLOW_SUSPEND_RESUME, MHD_USE_INTERNAL_POLLING_THREAD, MHD_USE_THREAD_PER_CONNECTION, NULL, MHD_Daemon::options, and MHD_Daemon::pid.

Here is the call graph for this function:

◆ MHD_upgrade_action()

_MHD_EXTERN enum MHD_Result MHD_upgrade_action ( struct MHD_UpgradeResponseHandle *  urh,
enum MHD_UpgradeAction  action,
  ... 
)

This connection-specific callback is provided by MHD to applications (unusual) during the MHD_UpgradeHandler. It allows applications to perform 'special' actions on the underlying socket from the upgrade.

Parameters
urhthe handle identifying the connection to perform the upgrade action on.
actionwhich action should be performed
...arguments to the action (depends on the action)
Returns
MHD_NO on error, MHD_YES on success

Variable Documentation

◆ data

◆ fd

◆ must_copy

void int int must_copy

Definition at line 3055 of file microhttpd.h.

Referenced by MHD_create_response_from_data().

◆ must_free

void int must_free

Definition at line 3054 of file microhttpd.h.

Referenced by MHD_create_response_from_data().

◆ offset