00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00070 #ifndef MHD_MICROHTTPD_H
00071 #define MHD_MICROHTTPD_H
00072
00073 #ifdef __cplusplus
00074 extern "C"
00075 {
00076 #if 0
00077 }
00078 #endif
00079 #endif
00080
00084 #define MHD_VERSION 0x00040002
00085
00089 #define MHD_YES 1
00090
00091 #define MHD_NO 0
00092
00096 #define MHD_HTTP_CONTINUE 100
00097 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
00098 #define MHD_HTTP_PROCESSING 102
00099
00100 #define MHD_HTTP_OK 200
00101 #define MHD_HTTP_CREATED 201
00102 #define MHD_HTTP_ACCEPTED 202
00103 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
00104 #define MHD_HTTP_NO_CONTENT 204
00105 #define MHD_HTTP_RESET_CONTENT 205
00106 #define MHD_HTTP_PARTIAL_CONTENT 206
00107 #define MHD_HTTP_MULTI_STATUS 207
00108
00109 #define MHD_HTTP_MULTIPLE_CHOICES 300
00110 #define MHD_HTTP_MOVED_PERMANENTLY 301
00111 #define MHD_HTTP_FOUND 302
00112 #define MHD_HTTP_SEE_OTHER 303
00113 #define MHD_HTTP_NOT_MODIFIED 304
00114 #define MHD_HTTP_USE_PROXY 305
00115 #define MHD_HTTP_SWITCH_PROXY 306
00116 #define MHD_HTTP_TEMPORARY_REDIRECT 307
00117
00118 #define MHD_HTTP_BAD_REQUEST 400
00119 #define MHD_HTTP_UNAUTHORIZED 401
00120 #define MHD_HTTP_PAYMENT_REQUIRED 402
00121 #define MHD_HTTP_FORBIDDEN 403
00122 #define MHD_HTTP_NOT_FOUND 404
00123 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
00124 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
00125 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
00126 #define MHD_HTTP_REQUEST_TIMEOUT 408
00127 #define MHD_HTTP_CONFLICT 409
00128 #define MHD_HTTP_GONE 410
00129 #define MHD_HTTP_LENGTH_REQUIRED 411
00130 #define MHD_HTTP_PRECONDITION_FAILED 412
00131 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
00132 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
00133 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
00134 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
00135 #define MHD_HTTP_EXPECTATION_FAILED 417
00136 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
00137 #define MHD_HTTP_LOCKED 423
00138 #define MHD_HTTP_FAILED_DEPENDENCY 424
00139 #define MHD_HTTP_UNORDERED_COLLECTION 425
00140 #define MHD_HTTP_UPGRADE_REQUIRED 426
00141 #define MHD_HTTP_RETRY_WITH 449
00142
00143 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
00144 #define MHD_HTTP_NOT_IMPLEMENTED 501
00145 #define MHD_HTTP_BAD_GATEWAY 502
00146 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
00147 #define MHD_HTTP_GATEWAY_TIMEOUT 504
00148 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
00149 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
00150 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
00151 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
00152 #define MHD_HTTP_NOT_EXTENDED 510
00153
00154
00155 #define MHD_HTTP_HEADER_ACCEPT "Accept"
00156 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
00157 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
00158 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
00159 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
00160 #define MHD_HTTP_HEADER_AGE "Age"
00161 #define MHD_HTTP_HEADER_ALLOW "Allow"
00162 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
00163 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
00164 #define MHD_HTTP_HEADER_CONNECTION "Connection"
00165 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
00166 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
00167 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
00168 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
00169 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
00170 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
00171 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
00172 #define MHD_HTTP_HEADER_DATE "Date"
00173 #define MHD_HTTP_HEADER_ETAG "ETag"
00174 #define MHD_HTTP_HEADER_EXPECT "Expect"
00175 #define MHD_HTTP_HEADER_EXPIRES "Expires"
00176 #define MHD_HTTP_HEADER_FROM "From"
00177 #define MHD_HTTP_HEADER_HOST "Host"
00178 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
00179 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
00180 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
00181 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
00182 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
00183 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
00184 #define MHD_HTTP_HEADER_LOCATION "Location"
00185 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
00186 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
00187 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
00188 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
00189 #define MHD_HTTP_HEADER_RANGE "Range"
00190 #define MHD_HTTP_HEADER_REFERER "Referer"
00191 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
00192 #define MHD_HTTP_HEADER_SERVER "Server"
00193 #define MHD_HTTP_HEADER_TE "TE"
00194 #define MHD_HTTP_HEADER_TRAILER "Trailer"
00195 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
00196 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
00197 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
00198 #define MHD_HTTP_HEADER_VARY "Vary"
00199 #define MHD_HTTP_HEADER_VIA "Via"
00200 #define MHD_HTTP_HEADER_WARNING "Warning"
00201 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
00202
00207 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
00208 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
00209
00213 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
00214 #define MHD_HTTP_METHOD_DELETE "DELETE"
00215 #define MHD_HTTP_METHOD_GET "GET"
00216 #define MHD_HTTP_METHOD_HEAD "HEAD"
00217 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
00218 #define MHD_HTTP_METHOD_POST "POST"
00219 #define MHD_HTTP_METHOD_PUT "PUT"
00220 #define MHD_HTTP_METHOD_TRACE "TRACE"
00221
00226 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
00227 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
00228
00239 enum MHD_FLAG
00240 {
00244 MHD_NO_FLAG = 0,
00245
00251 MHD_USE_DEBUG = 1,
00252
00256 MHD_USE_SSL = 2,
00257
00261 MHD_USE_THREAD_PER_CONNECTION = 4,
00262
00266 MHD_USE_SELECT_INTERNALLY = 8,
00267
00272 MHD_USE_IPv6 = 16,
00273
00283 MHD_USE_PEDANTIC_CHECKS = 32
00284 };
00285
00290 enum MHD_OPTION
00291 {
00292
00297 MHD_OPTION_END = 0,
00298
00303 MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1,
00304
00309 MHD_OPTION_CONNECTION_LIMIT = 2,
00310
00316 MHD_OPTION_CONNECTION_TIMEOUT = 3,
00317
00330 MHD_OPTION_NOTIFY_COMPLETED = 4,
00331
00342 MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5,
00343
00349 MHD_OPTION_SOCK_ADDR = 6,
00350
00372 MHD_OPTION_URI_LOG_CALLBACK = 7,
00373
00380 MHD_OPTION_HTTPS_MEM_KEY = 8,
00381
00388 MHD_OPTION_HTTPS_MEM_CERT = 9,
00389
00395 MHD_OPTION_CRED_TYPE = 10,
00396
00405 MHD_OPTION_PROTOCOL_VERSION = 11,
00406
00413 MHD_OPTION_CIPHER_ALGORITHM = 12,
00414
00427 MHD_OPTION_EXTERNAL_LOGGER = 13
00428
00429 };
00430
00435 enum MHD_ValueKind
00436 {
00437
00441 MHD_RESPONSE_HEADER_KIND = 0,
00442
00446 MHD_HEADER_KIND = 1,
00447
00452 MHD_COOKIE_KIND = 2,
00453
00462 MHD_POSTDATA_KIND = 4,
00463
00467 MHD_GET_ARGUMENT_KIND = 8,
00468
00472 MHD_FOOTER_KIND = 16
00473 };
00474
00479 enum MHD_RequestTerminationCode
00480 {
00481
00485 MHD_REQUEST_TERMINATED_COMPLETED_OK = 0,
00486
00492 MHD_REQUEST_TERMINATED_WITH_ERROR = 1,
00493
00499 MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2,
00500
00505 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3
00506
00507 };
00508
00514 enum MHD_GNUTLS_CipherAlgorithm
00515 {
00516 MHD_GNUTLS_CIPHER_UNKNOWN = 0,
00517 MHD_GNUTLS_CIPHER_NULL = 1,
00518 MHD_GNUTLS_CIPHER_ARCFOUR_128,
00519 MHD_GNUTLS_CIPHER_3DES_CBC,
00520 MHD_GNUTLS_CIPHER_AES_128_CBC,
00521 MHD_GNUTLS_CIPHER_AES_256_CBC
00522 };
00523
00529 enum MHD_GNUTLS_Protocol
00530 {
00531 MHD_GNUTLS_PROTOCOL_END = 0,
00532 MHD_GNUTLS_PROTOCOL_SSL3 = 1,
00533 MHD_GNUTLS_PROTOCOL_TLS1_0,
00534 MHD_GNUTLS_PROTOCOL_TLS1_1,
00535 MHD_GNUTLS_PROTOCOL_TLS1_2,
00536 MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN = 0xff
00537 };
00538
00543 enum MHD_ConnectionInfoType
00544 {
00549 MHD_CONNECTION_INFO_CIPHER_ALGO,
00550
00555 MHD_CONNECTION_INFO_PROTOCOL,
00556
00561 MHD_CONNECTION_INFO_CLIENT_ADDRESS
00562 };
00563
00568 enum MHD_DaemonInfoType
00569 {
00576 MHD_DAEMON_INFO_KEY_SIZE,
00577
00584 MHD_DAEMON_INFO_MAC_KEY_SIZE
00585 };
00586
00587
00588
00592 struct MHD_Daemon;
00593
00600 struct MHD_Connection;
00601
00605 struct MHD_Response;
00606
00610 struct MHD_PostProcessor;
00611
00619 typedef int
00620 (*MHD_AcceptPolicyCallback) (void *cls,
00621 const struct sockaddr * addr,
00622 socklen_t addrlen);
00623
00659 typedef int
00660 (*MHD_AccessHandlerCallback) (void *cls,
00661 struct MHD_Connection * connection,
00662 const char *url,
00663 const char *method,
00664 const char *version,
00665 const char *upload_data,
00666 size_t *upload_data_size,
00667 void **con_cls);
00668
00680 typedef void
00681 (*MHD_RequestCompletedCallback) (void *cls,
00682 struct MHD_Connection * connection,
00683 void **con_cls,
00684 enum MHD_RequestTerminationCode toe);
00685
00696 typedef int
00697 (*MHD_KeyValueIterator) (void *cls,
00698 enum MHD_ValueKind kind,
00699 const char *key, const char *value);
00700
00733 typedef int
00734 (*MHD_ContentReaderCallback) (void *cls,
00735 uint64_t pos,
00736 char *buf,
00737 int max);
00738
00745 typedef void (*MHD_ContentReaderFreeCallback) (void *cls);
00746
00766 typedef int
00767 (*MHD_PostDataIterator) (void *cls,
00768 enum MHD_ValueKind kind,
00769 const char *key,
00770 const char *filename,
00771 const char *content_type,
00772 const char *transfer_encoding,
00773 const char *data, uint64_t off, size_t size);
00774
00775
00776
00793 struct MHD_Daemon *MHD_start_daemon_va (unsigned int options,
00794 unsigned short port,
00795 MHD_AcceptPolicyCallback apc,
00796 void *apc_cls,
00797 MHD_AccessHandlerCallback dh,
00798 void *dh_cls, va_list ap);
00799
00815 struct MHD_Daemon *MHD_start_daemon (unsigned int flags,
00816 unsigned short port,
00817 MHD_AcceptPolicyCallback apc,
00818 void *apc_cls,
00819 MHD_AccessHandlerCallback dh,
00820 void *dh_cls, ...);
00821
00827 void MHD_stop_daemon (struct MHD_Daemon *daemon);
00828
00829
00843 int
00844 MHD_get_fdset (struct MHD_Daemon *daemon,
00845 fd_set * read_fd_set,
00846 fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd);
00847
00860 int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
00861
00862
00874 int MHD_run (struct MHD_Daemon *daemon);
00875
00876
00877
00878
00889 int
00890 MHD_get_connection_values (struct MHD_Connection *connection,
00891 enum MHD_ValueKind kind,
00892 MHD_KeyValueIterator iterator, void *iterator_cls);
00893
00923 int
00924 MHD_set_connection_value (struct MHD_Connection *connection,
00925 enum MHD_ValueKind kind,
00926 const char *key, const char *value);
00927
00937 const char *MHD_lookup_connection_value (struct MHD_Connection *connection,
00938 enum MHD_ValueKind kind,
00939 const char *key);
00940
00951 int
00952 MHD_queue_response (struct MHD_Connection *connection,
00953 unsigned int status_code, struct MHD_Response *response);
00954
00955
00956
00957
00973 struct MHD_Response *MHD_create_response_from_callback (uint64_t size,
00974 size_t block_size,
00975 MHD_ContentReaderCallback
00976 crc, void *crc_cls,
00977 MHD_ContentReaderFreeCallback
00978 crfc);
00979
00992 struct MHD_Response *MHD_create_response_from_data (size_t size,
00993 void *data,
00994 int must_free,
00995 int must_copy);
00996
01005 void MHD_destroy_response (struct MHD_Response *response);
01006
01016 int
01017 MHD_add_response_header (struct MHD_Response *response,
01018 const char *header, const char *content);
01019
01028 int
01029 MHD_del_response_header (struct MHD_Response *response,
01030 const char *header, const char *content);
01031
01041 int
01042 MHD_get_response_headers (struct MHD_Response *response,
01043 MHD_KeyValueIterator iterator, void *iterator_cls);
01044
01045
01053 const char *MHD_get_response_header (struct MHD_Response *response,
01054 const char *key);
01055
01056
01057
01058
01082 struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection
01083 *connection,
01084 size_t buffer_size,
01085 MHD_PostDataIterator
01086 iter, void *cls);
01087
01102 int
01103 MHD_post_process (struct MHD_PostProcessor *pp,
01104 const char *post_data, size_t post_data_len);
01105
01115 int MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
01116
01117
01118
01119
01120
01121
01125 union MHD_ConnectionInfo
01126 {
01127 enum MHD_GNUTLS_CipherAlgorithm cipher_algorithm;
01128 enum MHD_GNUTLS_Protocol protocol;
01132 struct sockaddr_in * client_addr;
01133 };
01134
01144 const union MHD_ConnectionInfo *MHD_get_connection_info (struct MHD_Connection
01145 *connection,
01146 enum
01147 MHD_ConnectionInfoType
01148 infoType, ...);
01149
01150
01154 union MHD_DaemonInfo
01155 {
01159 size_t key_size;
01160
01164 size_t mac_key_size;
01165 };
01166
01177 const union MHD_DaemonInfo *MHD_get_daemon_info (struct MHD_Daemon *daemon,
01178 enum MHD_DaemonInfoType
01179 infoType, ...);
01180
01181 #if 0
01182 {
01183 #endif
01184 #ifdef __cplusplus
01185 }
01186 #endif
01187
01188 #endif