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 0x00040200
00085
00089 #define MHD_YES 1
00090
00091 #define MHD_NO 0
00092
00096 #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
00097
00101 #define MHD_HTTP_CONTINUE 100
00102 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
00103 #define MHD_HTTP_PROCESSING 102
00104
00105 #define MHD_HTTP_OK 200
00106 #define MHD_HTTP_CREATED 201
00107 #define MHD_HTTP_ACCEPTED 202
00108 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
00109 #define MHD_HTTP_NO_CONTENT 204
00110 #define MHD_HTTP_RESET_CONTENT 205
00111 #define MHD_HTTP_PARTIAL_CONTENT 206
00112 #define MHD_HTTP_MULTI_STATUS 207
00113
00114 #define MHD_HTTP_MULTIPLE_CHOICES 300
00115 #define MHD_HTTP_MOVED_PERMANENTLY 301
00116 #define MHD_HTTP_FOUND 302
00117 #define MHD_HTTP_SEE_OTHER 303
00118 #define MHD_HTTP_NOT_MODIFIED 304
00119 #define MHD_HTTP_USE_PROXY 305
00120 #define MHD_HTTP_SWITCH_PROXY 306
00121 #define MHD_HTTP_TEMPORARY_REDIRECT 307
00122
00123 #define MHD_HTTP_BAD_REQUEST 400
00124 #define MHD_HTTP_UNAUTHORIZED 401
00125 #define MHD_HTTP_PAYMENT_REQUIRED 402
00126 #define MHD_HTTP_FORBIDDEN 403
00127 #define MHD_HTTP_NOT_FOUND 404
00128 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
00129 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
00130 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
00131 #define MHD_HTTP_REQUEST_TIMEOUT 408
00132 #define MHD_HTTP_CONFLICT 409
00133 #define MHD_HTTP_GONE 410
00134 #define MHD_HTTP_LENGTH_REQUIRED 411
00135 #define MHD_HTTP_PRECONDITION_FAILED 412
00136 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
00137 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
00138 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
00139 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
00140 #define MHD_HTTP_EXPECTATION_FAILED 417
00141 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
00142 #define MHD_HTTP_LOCKED 423
00143 #define MHD_HTTP_FAILED_DEPENDENCY 424
00144 #define MHD_HTTP_UNORDERED_COLLECTION 425
00145 #define MHD_HTTP_UPGRADE_REQUIRED 426
00146 #define MHD_HTTP_RETRY_WITH 449
00147
00148 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
00149 #define MHD_HTTP_NOT_IMPLEMENTED 501
00150 #define MHD_HTTP_BAD_GATEWAY 502
00151 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
00152 #define MHD_HTTP_GATEWAY_TIMEOUT 504
00153 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
00154 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
00155 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
00156 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
00157 #define MHD_HTTP_NOT_EXTENDED 510
00158
00159
00160 #define MHD_HTTP_HEADER_ACCEPT "Accept"
00161 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
00162 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
00163 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
00164 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
00165 #define MHD_HTTP_HEADER_AGE "Age"
00166 #define MHD_HTTP_HEADER_ALLOW "Allow"
00167 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
00168 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
00169 #define MHD_HTTP_HEADER_CONNECTION "Connection"
00170 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
00171 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
00172 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
00173 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
00174 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
00175 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
00176 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
00177 #define MHD_HTTP_HEADER_DATE "Date"
00178 #define MHD_HTTP_HEADER_ETAG "ETag"
00179 #define MHD_HTTP_HEADER_EXPECT "Expect"
00180 #define MHD_HTTP_HEADER_EXPIRES "Expires"
00181 #define MHD_HTTP_HEADER_FROM "From"
00182 #define MHD_HTTP_HEADER_HOST "Host"
00183 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
00184 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
00185 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
00186 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
00187 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
00188 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
00189 #define MHD_HTTP_HEADER_LOCATION "Location"
00190 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
00191 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
00192 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
00193 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
00194 #define MHD_HTTP_HEADER_RANGE "Range"
00195 #define MHD_HTTP_HEADER_REFERER "Referer"
00196 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
00197 #define MHD_HTTP_HEADER_SERVER "Server"
00198 #define MHD_HTTP_HEADER_TE "TE"
00199 #define MHD_HTTP_HEADER_TRAILER "Trailer"
00200 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
00201 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
00202 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
00203 #define MHD_HTTP_HEADER_VARY "Vary"
00204 #define MHD_HTTP_HEADER_VIA "Via"
00205 #define MHD_HTTP_HEADER_WARNING "Warning"
00206 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
00207
00212 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
00213 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
00214
00218 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
00219 #define MHD_HTTP_METHOD_DELETE "DELETE"
00220 #define MHD_HTTP_METHOD_GET "GET"
00221 #define MHD_HTTP_METHOD_HEAD "HEAD"
00222 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
00223 #define MHD_HTTP_METHOD_POST "POST"
00224 #define MHD_HTTP_METHOD_PUT "PUT"
00225 #define MHD_HTTP_METHOD_TRACE "TRACE"
00226
00231 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
00232 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
00233
00244 enum MHD_FLAG
00245 {
00249 MHD_NO_FLAG = 0,
00250
00256 MHD_USE_DEBUG = 1,
00257
00261 MHD_USE_SSL = 2,
00262
00266 MHD_USE_THREAD_PER_CONNECTION = 4,
00267
00271 MHD_USE_SELECT_INTERNALLY = 8,
00272
00277 MHD_USE_IPv6 = 16,
00278
00288 MHD_USE_PEDANTIC_CHECKS = 32
00289 };
00290
00295 enum MHD_OPTION
00296 {
00297
00302 MHD_OPTION_END = 0,
00303
00308 MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1,
00309
00314 MHD_OPTION_CONNECTION_LIMIT = 2,
00315
00321 MHD_OPTION_CONNECTION_TIMEOUT = 3,
00322
00335 MHD_OPTION_NOTIFY_COMPLETED = 4,
00336
00347 MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5,
00348
00354 MHD_OPTION_SOCK_ADDR = 6,
00355
00377 MHD_OPTION_URI_LOG_CALLBACK = 7,
00378
00385 MHD_OPTION_HTTPS_MEM_KEY = 8,
00386
00393 MHD_OPTION_HTTPS_MEM_CERT = 9,
00394
00400 MHD_OPTION_CRED_TYPE = 10,
00401
00410 MHD_OPTION_PROTOCOL_VERSION = 11,
00411
00418 MHD_OPTION_CIPHER_ALGORITHM = 12,
00419
00432 MHD_OPTION_EXTERNAL_LOGGER = 13,
00433
00442 MHD_OPTION_THREAD_POOL_SIZE = 14
00443 };
00444
00449 enum MHD_ValueKind
00450 {
00451
00455 MHD_RESPONSE_HEADER_KIND = 0,
00456
00460 MHD_HEADER_KIND = 1,
00461
00466 MHD_COOKIE_KIND = 2,
00467
00476 MHD_POSTDATA_KIND = 4,
00477
00481 MHD_GET_ARGUMENT_KIND = 8,
00482
00486 MHD_FOOTER_KIND = 16
00487 };
00488
00493 enum MHD_RequestTerminationCode
00494 {
00495
00499 MHD_REQUEST_TERMINATED_COMPLETED_OK = 0,
00500
00506 MHD_REQUEST_TERMINATED_WITH_ERROR = 1,
00507
00513 MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2,
00514
00519 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3
00520
00521 };
00522
00528 enum MHD_GNUTLS_CipherAlgorithm
00529 {
00530 MHD_GNUTLS_CIPHER_UNKNOWN = 0,
00531 MHD_GNUTLS_CIPHER_NULL = 1,
00532 MHD_GNUTLS_CIPHER_ARCFOUR_128,
00533 MHD_GNUTLS_CIPHER_3DES_CBC,
00534 MHD_GNUTLS_CIPHER_AES_128_CBC,
00535 MHD_GNUTLS_CIPHER_AES_256_CBC
00536 };
00537
00543 enum MHD_GNUTLS_Protocol
00544 {
00545 MHD_GNUTLS_PROTOCOL_END = 0,
00546 MHD_GNUTLS_PROTOCOL_SSL3 = 1,
00547 MHD_GNUTLS_PROTOCOL_TLS1_0,
00548 MHD_GNUTLS_PROTOCOL_TLS1_1,
00549 MHD_GNUTLS_PROTOCOL_TLS1_2,
00550 MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN = 0xff
00551 };
00552
00557 enum MHD_ConnectionInfoType
00558 {
00563 MHD_CONNECTION_INFO_CIPHER_ALGO,
00564
00569 MHD_CONNECTION_INFO_PROTOCOL,
00570
00575 MHD_CONNECTION_INFO_CLIENT_ADDRESS
00576 };
00577
00582 enum MHD_DaemonInfoType
00583 {
00590 MHD_DAEMON_INFO_KEY_SIZE,
00591
00598 MHD_DAEMON_INFO_MAC_KEY_SIZE
00599 };
00600
00601
00602
00606 struct MHD_Daemon;
00607
00614 struct MHD_Connection;
00615
00619 struct MHD_Response;
00620
00624 struct MHD_PostProcessor;
00625
00633 typedef int
00634 (*MHD_AcceptPolicyCallback) (void *cls,
00635 const struct sockaddr * addr,
00636 socklen_t addrlen);
00637
00673 typedef int
00674 (*MHD_AccessHandlerCallback) (void *cls,
00675 struct MHD_Connection * connection,
00676 const char *url,
00677 const char *method,
00678 const char *version,
00679 const char *upload_data,
00680 size_t *upload_data_size,
00681 void **con_cls);
00682
00694 typedef void
00695 (*MHD_RequestCompletedCallback) (void *cls,
00696 struct MHD_Connection * connection,
00697 void **con_cls,
00698 enum MHD_RequestTerminationCode toe);
00699
00710 typedef int
00711 (*MHD_KeyValueIterator) (void *cls,
00712 enum MHD_ValueKind kind,
00713 const char *key, const char *value);
00714
00747 typedef int
00748 (*MHD_ContentReaderCallback) (void *cls,
00749 uint64_t pos,
00750 char *buf,
00751 int max);
00752
00759 typedef void (*MHD_ContentReaderFreeCallback) (void *cls);
00760
00780 typedef int
00781 (*MHD_PostDataIterator) (void *cls,
00782 enum MHD_ValueKind kind,
00783 const char *key,
00784 const char *filename,
00785 const char *content_type,
00786 const char *transfer_encoding,
00787 const char *data, uint64_t off, size_t size);
00788
00789
00790
00807 struct MHD_Daemon *MHD_start_daemon_va (unsigned int options,
00808 unsigned short port,
00809 MHD_AcceptPolicyCallback apc,
00810 void *apc_cls,
00811 MHD_AccessHandlerCallback dh,
00812 void *dh_cls, va_list ap);
00813
00829 struct MHD_Daemon *MHD_start_daemon (unsigned int flags,
00830 unsigned short port,
00831 MHD_AcceptPolicyCallback apc,
00832 void *apc_cls,
00833 MHD_AccessHandlerCallback dh,
00834 void *dh_cls, ...);
00835
00841 void MHD_stop_daemon (struct MHD_Daemon *daemon);
00842
00843
00857 int
00858 MHD_get_fdset (struct MHD_Daemon *daemon,
00859 fd_set * read_fd_set,
00860 fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd);
00861
00874 int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
00875
00876
00888 int MHD_run (struct MHD_Daemon *daemon);
00889
00890
00891
00892
00903 int
00904 MHD_get_connection_values (struct MHD_Connection *connection,
00905 enum MHD_ValueKind kind,
00906 MHD_KeyValueIterator iterator, void *iterator_cls);
00907
00937 int
00938 MHD_set_connection_value (struct MHD_Connection *connection,
00939 enum MHD_ValueKind kind,
00940 const char *key, const char *value);
00941
00951 const char *MHD_lookup_connection_value (struct MHD_Connection *connection,
00952 enum MHD_ValueKind kind,
00953 const char *key);
00954
00965 int
00966 MHD_queue_response (struct MHD_Connection *connection,
00967 unsigned int status_code, struct MHD_Response *response);
00968
00969
00970
00971
00987 struct MHD_Response *MHD_create_response_from_callback (uint64_t size,
00988 size_t block_size,
00989 MHD_ContentReaderCallback
00990 crc, void *crc_cls,
00991 MHD_ContentReaderFreeCallback
00992 crfc);
00993
01006 struct MHD_Response *MHD_create_response_from_data (size_t size,
01007 void *data,
01008 int must_free,
01009 int must_copy);
01010
01019 void MHD_destroy_response (struct MHD_Response *response);
01020
01030 int
01031 MHD_add_response_header (struct MHD_Response *response,
01032 const char *header, const char *content);
01033
01042 int
01043 MHD_del_response_header (struct MHD_Response *response,
01044 const char *header, const char *content);
01045
01055 int
01056 MHD_get_response_headers (struct MHD_Response *response,
01057 MHD_KeyValueIterator iterator, void *iterator_cls);
01058
01059
01067 const char *MHD_get_response_header (struct MHD_Response *response,
01068 const char *key);
01069
01070
01071
01072
01096 struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection
01097 *connection,
01098 size_t buffer_size,
01099 MHD_PostDataIterator
01100 iter, void *cls);
01101
01116 int
01117 MHD_post_process (struct MHD_PostProcessor *pp,
01118 const char *post_data, size_t post_data_len);
01119
01129 int MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
01130
01131
01132
01133
01134
01135
01139 union MHD_ConnectionInfo
01140 {
01141 enum MHD_GNUTLS_CipherAlgorithm cipher_algorithm;
01142 enum MHD_GNUTLS_Protocol protocol;
01146 struct sockaddr_in * client_addr;
01147 };
01148
01158 const union MHD_ConnectionInfo *MHD_get_connection_info (struct MHD_Connection
01159 *connection,
01160 enum
01161 MHD_ConnectionInfoType
01162 infoType, ...);
01163
01164
01168 union MHD_DaemonInfo
01169 {
01173 size_t key_size;
01174
01178 size_t mac_key_size;
01179 };
01180
01191 const union MHD_DaemonInfo *MHD_get_daemon_info (struct MHD_Daemon *daemon,
01192 enum MHD_DaemonInfoType
01193 infoType, ...);
01194
01200 const char* MHD_get_version(void);
01201
01202 #if 0
01203 {
01204 #endif
01205 #ifdef __cplusplus
01206 }
01207 #endif
01208
01209 #endif