86 #ifndef MHD_MICROHTTPD_H
87 #define MHD_MICROHTTPD_H
107 #ifndef MHD_PLATFORM_H
110 #if defined(_WIN32) && !defined(__CYGWIN__)
111 #include <ws2tcpip.h>
114 #include <sys/time.h>
115 #include <sys/types.h>
116 #include <sys/socket.h>
120 #if defined(__CYGWIN__) && !defined(_SYS_TYPES_FD_SET)
122 #error Cygwin with winsock fd_set is not supported
129 #define MHD_VERSION 0x00093400
144 #define MHD_INVALID_NONCE -1
151 #define MHD_SIZE_UNKNOWN UINT64_MAX
153 #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
157 #define MHD_CONTENT_READER_END_OF_STREAM SIZE_MAX
158 #define MHD_CONTENT_READER_END_WITH_ERROR (SIZE_MAX - 1)
160 #define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL)
161 #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1)
165 #define _MHD_EXTERN extern
168 #ifndef MHD_SOCKET_DEFINED
172 #if !defined(_WIN32) || defined(_SYS_TYPES_FD_SET)
173 #define MHD_POSIX_SOCKETS 1
175 #define MHD_INVALID_SOCKET (-1)
177 #define MHD_WINSOCK_SOCKETS 1
178 #include <winsock2.h>
180 #define MHD_INVALID_SOCKET (INVALID_SOCKET)
182 #define MHD_SOCKET_DEFINED 1
190 #ifndef MHD_LONG_LONG
194 #define MHD_LONG_LONG long long
195 #define MHD_UNSIGNED_LONG_LONG unsigned long long
201 #ifndef MHD_LONG_LONG_PRINTF
205 #define MHD_LONG_LONG_PRINTF "ll"
206 #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu"
215 #define MHD_HTTP_CONTINUE 100
216 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
217 #define MHD_HTTP_PROCESSING 102
219 #define MHD_HTTP_OK 200
220 #define MHD_HTTP_CREATED 201
221 #define MHD_HTTP_ACCEPTED 202
222 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
223 #define MHD_HTTP_NO_CONTENT 204
224 #define MHD_HTTP_RESET_CONTENT 205
225 #define MHD_HTTP_PARTIAL_CONTENT 206
226 #define MHD_HTTP_MULTI_STATUS 207
228 #define MHD_HTTP_MULTIPLE_CHOICES 300
229 #define MHD_HTTP_MOVED_PERMANENTLY 301
230 #define MHD_HTTP_FOUND 302
231 #define MHD_HTTP_SEE_OTHER 303
232 #define MHD_HTTP_NOT_MODIFIED 304
233 #define MHD_HTTP_USE_PROXY 305
234 #define MHD_HTTP_SWITCH_PROXY 306
235 #define MHD_HTTP_TEMPORARY_REDIRECT 307
237 #define MHD_HTTP_BAD_REQUEST 400
238 #define MHD_HTTP_UNAUTHORIZED 401
239 #define MHD_HTTP_PAYMENT_REQUIRED 402
240 #define MHD_HTTP_FORBIDDEN 403
241 #define MHD_HTTP_NOT_FOUND 404
242 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
243 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
244 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
245 #define MHD_HTTP_REQUEST_TIMEOUT 408
246 #define MHD_HTTP_CONFLICT 409
247 #define MHD_HTTP_GONE 410
248 #define MHD_HTTP_LENGTH_REQUIRED 411
249 #define MHD_HTTP_PRECONDITION_FAILED 412
250 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
251 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
252 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
253 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
254 #define MHD_HTTP_EXPECTATION_FAILED 417
255 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
256 #define MHD_HTTP_LOCKED 423
257 #define MHD_HTTP_FAILED_DEPENDENCY 424
258 #define MHD_HTTP_UNORDERED_COLLECTION 425
259 #define MHD_HTTP_UPGRADE_REQUIRED 426
260 #define MHD_HTTP_NO_RESPONSE 444
261 #define MHD_HTTP_RETRY_WITH 449
262 #define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS 450
263 #define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451
265 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
266 #define MHD_HTTP_NOT_IMPLEMENTED 501
267 #define MHD_HTTP_BAD_GATEWAY 502
268 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
269 #define MHD_HTTP_GATEWAY_TIMEOUT 504
270 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
271 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
272 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
273 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
274 #define MHD_HTTP_NOT_EXTENDED 510
284 #define MHD_ICY_FLAG ((uint32_t)(1 << 31))
292 #define MHD_HTTP_HEADER_ACCEPT "Accept"
293 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
294 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
295 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
296 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
297 #define MHD_HTTP_HEADER_AGE "Age"
298 #define MHD_HTTP_HEADER_ALLOW "Allow"
299 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
300 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
301 #define MHD_HTTP_HEADER_CONNECTION "Connection"
302 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
303 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
304 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
305 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
306 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
307 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
308 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
309 #define MHD_HTTP_HEADER_COOKIE "Cookie"
310 #define MHD_HTTP_HEADER_DATE "Date"
311 #define MHD_HTTP_HEADER_ETAG "ETag"
312 #define MHD_HTTP_HEADER_EXPECT "Expect"
313 #define MHD_HTTP_HEADER_EXPIRES "Expires"
314 #define MHD_HTTP_HEADER_FROM "From"
315 #define MHD_HTTP_HEADER_HOST "Host"
316 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
317 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
318 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
319 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
320 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
321 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
322 #define MHD_HTTP_HEADER_LOCATION "Location"
323 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
324 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
325 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
326 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
327 #define MHD_HTTP_HEADER_RANGE "Range"
329 #define MHD_HTTP_HEADER_REFERER "Referer"
330 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
331 #define MHD_HTTP_HEADER_SERVER "Server"
332 #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie"
333 #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2"
334 #define MHD_HTTP_HEADER_TE "TE"
335 #define MHD_HTTP_HEADER_TRAILER "Trailer"
336 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
337 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
338 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
339 #define MHD_HTTP_HEADER_VARY "Vary"
340 #define MHD_HTTP_HEADER_VIA "Via"
341 #define MHD_HTTP_HEADER_WARNING "Warning"
342 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
343 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN "Access-Control-Allow-Origin"
353 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
354 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
363 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
364 #define MHD_HTTP_METHOD_DELETE "DELETE"
365 #define MHD_HTTP_METHOD_GET "GET"
366 #define MHD_HTTP_METHOD_HEAD "HEAD"
367 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
368 #define MHD_HTTP_METHOD_POST "POST"
369 #define MHD_HTTP_METHOD_PUT "PUT"
370 #define MHD_HTTP_METHOD_TRACE "TRACE"
379 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
380 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
411 struct MHD_PostProcessor;
1119 const char *reason);
1130 const struct sockaddr *addr,
1179 const char *upload_data,
1180 size_t *upload_data_size,
1217 const char *key,
const char *value);
1307 const char *filename,
1308 const char *content_type,
1309 const char *transfer_encoding,
1430 const struct sockaddr *addr,
1453 fd_set *read_fd_set,
1454 fd_set *write_fd_set,
1455 fd_set *except_fd_set,
1522 const fd_set *read_fd_set,
1523 const fd_set *write_fd_set,
1524 const fd_set *except_fd_set);
1629 unsigned int status_code,
1818 enum MHD_UpgradeEventMask
1825 MHD_UPGRADE_EVENT_TERMINATE = 0,
1831 MHD_UPGRADE_EVENT_READ = 1,
1837 MHD_UPGRADE_EVENT_WRITE = 2,
1846 MHD_UPGRADE_EVENT_EXTERNAL = 4,
1855 MHD_UPGRADE_EVENT_CORK = 8
1903 typedef enum MHD_UpgradeEventMask (*MHD_UpgradeHandler)(
void *cls,
1906 size_t *data_in_size,
1907 const char *data_in,
1908 size_t *data_out_size,
1942 MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler,
1943 void *upgrade_handler_cls);
1972 const char *content);
1987 const char *content);
2002 const char *content);
2081 const char *post_data,
size_t post_data_len);
2106 #define MHD_INVALID_NONCE -1
2137 const char *username,
2138 const char *password,
2139 unsigned int nonce_timeout);
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
_MHD_EXTERN 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)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_callback(uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc)
_MHD_EXTERN const char * MHD_get_version(void)
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
_MHD_EXTERN int MHD_add_response_header(struct MHD_Response *response, const char *header, const char *content)
MHD_ContentReaderFreeCallback crfc
_MHD_EXTERN int MHD_get_timeout(struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
void(* MHD_ContentReaderFreeCallback)(void *cls)
_MHD_EXTERN int MHD_add_connection(struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset(size_t size, int fd, off_t offset)
_MHD_EXTERN int MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
MHD_RequestTerminationCode
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)
_MHD_EXTERN int MHD_destroy_post_processor(struct MHD_PostProcessor *pp)
_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 struct MHD_Daemon * MHD_start_daemon(unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...)
_MHD_EXTERN void MHD_set_panic_func(MHD_PanicCallback cb, void *cls)
#define MHD_UNSIGNED_LONG_LONG
_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 const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
_MHD_EXTERN char * MHD_basic_auth_get_username_password(struct MHD_Connection *connection, char **password)
_MHD_EXTERN void MHD_stop_daemon(struct MHD_Daemon *daemon)
_MHD_EXTERN int MHD_queue_auth_fail_response(struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale)
_MHD_EXTERN int MHD_add_response_footer(struct MHD_Response *response, const char *footer, const char *content)
_MHD_EXTERN 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)
_MHD_EXTERN char * MHD_digest_auth_get_username(struct MHD_Connection *connection)
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
_MHD_EXTERN void MHD_suspend_connection(struct MHD_Connection *connection)
int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
_MHD_EXTERN int MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
struct MHD_Daemon * daemon
_MHD_EXTERN int MHD_post_process(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd(size_t size, int fd)
_MHD_EXTERN int MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
MHD_AcceptPolicyCallback apc
_MHD_EXTERN int 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 int MHD_get_connection_values(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
_MHD_EXTERN int MHD_run(struct MHD_Daemon *daemon)
MHD_ContentReaderCallback crc
struct sockaddr * client_addr
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)
_MHD_EXTERN int MHD_del_response_header(struct MHD_Response *response, const char *header, const char *content)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_data(size_t size, void *data, int must_free, int must_copy)
_MHD_EXTERN const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
_MHD_EXTERN MHD_socket MHD_quiesce_daemon(struct MHD_Daemon *daemon)
_MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info(struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type,...)
_MHD_EXTERN int MHD_set_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value)
MHD_FLAG
Flags for the struct MHD_Daemon.
_MHD_EXTERN int MHD_get_response_headers(struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)
void(* MHD_LogCallback)(void *cls, const char *fm, va_list ap)
_MHD_EXTERN void MHD_resume_connection(struct MHD_Connection *connection)
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)