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 0x00040600
00085
00089 #define MHD_YES 1
00090
00094 #define MHD_NO 0
00095
00100 #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
00101
00105 #define MHD_HTTP_CONTINUE 100
00106 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
00107 #define MHD_HTTP_PROCESSING 102
00108
00109 #define MHD_HTTP_OK 200
00110 #define MHD_HTTP_CREATED 201
00111 #define MHD_HTTP_ACCEPTED 202
00112 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
00113 #define MHD_HTTP_NO_CONTENT 204
00114 #define MHD_HTTP_RESET_CONTENT 205
00115 #define MHD_HTTP_PARTIAL_CONTENT 206
00116 #define MHD_HTTP_MULTI_STATUS 207
00117
00118 #define MHD_HTTP_MULTIPLE_CHOICES 300
00119 #define MHD_HTTP_MOVED_PERMANENTLY 301
00120 #define MHD_HTTP_FOUND 302
00121 #define MHD_HTTP_SEE_OTHER 303
00122 #define MHD_HTTP_NOT_MODIFIED 304
00123 #define MHD_HTTP_USE_PROXY 305
00124 #define MHD_HTTP_SWITCH_PROXY 306
00125 #define MHD_HTTP_TEMPORARY_REDIRECT 307
00126
00127 #define MHD_HTTP_BAD_REQUEST 400
00128 #define MHD_HTTP_UNAUTHORIZED 401
00129 #define MHD_HTTP_PAYMENT_REQUIRED 402
00130 #define MHD_HTTP_FORBIDDEN 403
00131 #define MHD_HTTP_NOT_FOUND 404
00132 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
00133 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
00134 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
00135 #define MHD_HTTP_REQUEST_TIMEOUT 408
00136 #define MHD_HTTP_CONFLICT 409
00137 #define MHD_HTTP_GONE 410
00138 #define MHD_HTTP_LENGTH_REQUIRED 411
00139 #define MHD_HTTP_PRECONDITION_FAILED 412
00140 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
00141 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
00142 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
00143 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
00144 #define MHD_HTTP_EXPECTATION_FAILED 417
00145 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
00146 #define MHD_HTTP_LOCKED 423
00147 #define MHD_HTTP_FAILED_DEPENDENCY 424
00148 #define MHD_HTTP_UNORDERED_COLLECTION 425
00149 #define MHD_HTTP_UPGRADE_REQUIRED 426
00150 #define MHD_HTTP_RETRY_WITH 449
00151
00152 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
00153 #define MHD_HTTP_NOT_IMPLEMENTED 501
00154 #define MHD_HTTP_BAD_GATEWAY 502
00155 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
00156 #define MHD_HTTP_GATEWAY_TIMEOUT 504
00157 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
00158 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
00159 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
00160 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
00161 #define MHD_HTTP_NOT_EXTENDED 510
00162
00163
00164 #define MHD_HTTP_HEADER_ACCEPT "Accept"
00165 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
00166 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
00167 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
00168 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
00169 #define MHD_HTTP_HEADER_AGE "Age"
00170 #define MHD_HTTP_HEADER_ALLOW "Allow"
00171 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
00172 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
00173 #define MHD_HTTP_HEADER_CONNECTION "Connection"
00174 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
00175 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
00176 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
00177 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
00178 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
00179 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
00180 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
00181 #define MHD_HTTP_HEADER_COOKIE "Cookie"
00182 #define MHD_HTTP_HEADER_DATE "Date"
00183 #define MHD_HTTP_HEADER_ETAG "ETag"
00184 #define MHD_HTTP_HEADER_EXPECT "Expect"
00185 #define MHD_HTTP_HEADER_EXPIRES "Expires"
00186 #define MHD_HTTP_HEADER_FROM "From"
00187 #define MHD_HTTP_HEADER_HOST "Host"
00188 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
00189 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
00190 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
00191 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
00192 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
00193 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
00194 #define MHD_HTTP_HEADER_LOCATION "Location"
00195 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
00196 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
00197 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
00198 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
00199 #define MHD_HTTP_HEADER_RANGE "Range"
00200 #define MHD_HTTP_HEADER_REFERER "Referer"
00201 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
00202 #define MHD_HTTP_HEADER_SERVER "Server"
00203 #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie"
00204 #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2"
00205 #define MHD_HTTP_HEADER_TE "TE"
00206 #define MHD_HTTP_HEADER_TRAILER "Trailer"
00207 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
00208 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
00209 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
00210 #define MHD_HTTP_HEADER_VARY "Vary"
00211 #define MHD_HTTP_HEADER_VIA "Via"
00212 #define MHD_HTTP_HEADER_WARNING "Warning"
00213 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
00214
00219 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
00220 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
00221
00225 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
00226 #define MHD_HTTP_METHOD_DELETE "DELETE"
00227 #define MHD_HTTP_METHOD_GET "GET"
00228 #define MHD_HTTP_METHOD_HEAD "HEAD"
00229 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
00230 #define MHD_HTTP_METHOD_POST "POST"
00231 #define MHD_HTTP_METHOD_PUT "PUT"
00232 #define MHD_HTTP_METHOD_TRACE "TRACE"
00233
00238 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
00239 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
00240
00251 enum MHD_FLAG
00252 {
00256 MHD_NO_FLAG = 0,
00257
00263 MHD_USE_DEBUG = 1,
00264
00268 MHD_USE_SSL = 2,
00269
00273 MHD_USE_THREAD_PER_CONNECTION = 4,
00274
00278 MHD_USE_SELECT_INTERNALLY = 8,
00279
00284 MHD_USE_IPv6 = 16,
00285
00295 MHD_USE_PEDANTIC_CHECKS = 32,
00296
00302 MHD_USE_POLL = 64
00303 };
00304
00309 enum MHD_OPTION
00310 {
00311
00316 MHD_OPTION_END = 0,
00317
00322 MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1,
00323
00328 MHD_OPTION_CONNECTION_LIMIT = 2,
00329
00335 MHD_OPTION_CONNECTION_TIMEOUT = 3,
00336
00349 MHD_OPTION_NOTIFY_COMPLETED = 4,
00350
00361 MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5,
00362
00368 MHD_OPTION_SOCK_ADDR = 6,
00369
00391 MHD_OPTION_URI_LOG_CALLBACK = 7,
00392
00399 MHD_OPTION_HTTPS_MEM_KEY = 8,
00400
00407 MHD_OPTION_HTTPS_MEM_CERT = 9,
00408
00414 MHD_OPTION_CRED_TYPE = 10,
00415
00424 MHD_OPTION_PROTOCOL_VERSION = 11,
00425
00432 MHD_OPTION_CIPHER_ALGORITHM = 12,
00433
00446 MHD_OPTION_EXTERNAL_LOGGER = 13,
00447
00456 MHD_OPTION_THREAD_POOL_SIZE = 14,
00457
00477 MHD_OPTION_ARRAY = 15
00478 };
00479
00480
00484 struct MHD_OptionItem
00485 {
00490 enum MHD_OPTION option;
00491
00497 intptr_t value;
00498
00503 void *ptr_value;
00504
00505 };
00506
00507
00512 enum MHD_ValueKind
00513 {
00514
00518 MHD_RESPONSE_HEADER_KIND = 0,
00519
00523 MHD_HEADER_KIND = 1,
00524
00529 MHD_COOKIE_KIND = 2,
00530
00539 MHD_POSTDATA_KIND = 4,
00540
00544 MHD_GET_ARGUMENT_KIND = 8,
00545
00549 MHD_FOOTER_KIND = 16
00550 };
00551
00556 enum MHD_RequestTerminationCode
00557 {
00558
00562 MHD_REQUEST_TERMINATED_COMPLETED_OK = 0,
00563
00569 MHD_REQUEST_TERMINATED_WITH_ERROR = 1,
00570
00576 MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2,
00577
00582 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3
00583
00584 };
00585
00591 enum MHD_GNUTLS_CipherAlgorithm
00592 {
00593 MHD_GNUTLS_CIPHER_UNKNOWN = 0,
00594 MHD_GNUTLS_CIPHER_NULL = 1,
00595 MHD_GNUTLS_CIPHER_ARCFOUR_128,
00596 MHD_GNUTLS_CIPHER_3DES_CBC,
00597 MHD_GNUTLS_CIPHER_AES_128_CBC,
00598 MHD_GNUTLS_CIPHER_AES_256_CBC
00599 };
00600
00606 enum MHD_GNUTLS_Protocol
00607 {
00608 MHD_GNUTLS_PROTOCOL_END = 0,
00609 MHD_GNUTLS_PROTOCOL_SSL3 = 1,
00610 MHD_GNUTLS_PROTOCOL_TLS1_0,
00611 MHD_GNUTLS_PROTOCOL_TLS1_1,
00612 MHD_GNUTLS_PROTOCOL_TLS1_2,
00613 MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN = 0xff
00614 };
00615
00620 enum MHD_ConnectionInfoType
00621 {
00626 MHD_CONNECTION_INFO_CIPHER_ALGO,
00627
00632 MHD_CONNECTION_INFO_PROTOCOL,
00633
00638 MHD_CONNECTION_INFO_CLIENT_ADDRESS
00639 };
00640
00645 enum MHD_DaemonInfoType
00646 {
00653 MHD_DAEMON_INFO_KEY_SIZE,
00654
00661 MHD_DAEMON_INFO_MAC_KEY_SIZE,
00662
00667 MHD_DAEMON_INFO_LISTEN_FD
00668 };
00669
00670
00671
00675 struct MHD_Daemon;
00676
00683 struct MHD_Connection;
00684
00688 struct MHD_Response;
00689
00693 struct MHD_PostProcessor;
00694
00702 typedef void (*MHD_PanicCallback) (void *cls,
00703 const char *file,
00704 unsigned int line,
00705 const char *reason);
00706
00714 typedef int
00715 (*MHD_AcceptPolicyCallback) (void *cls,
00716 const struct sockaddr * addr,
00717 socklen_t addrlen);
00718
00754 typedef int
00755 (*MHD_AccessHandlerCallback) (void *cls,
00756 struct MHD_Connection * connection,
00757 const char *url,
00758 const char *method,
00759 const char *version,
00760 const char *upload_data,
00761 size_t *upload_data_size,
00762 void **con_cls);
00763
00775 typedef void
00776 (*MHD_RequestCompletedCallback) (void *cls,
00777 struct MHD_Connection * connection,
00778 void **con_cls,
00779 enum MHD_RequestTerminationCode toe);
00780
00791 typedef int
00792 (*MHD_KeyValueIterator) (void *cls,
00793 enum MHD_ValueKind kind,
00794 const char *key, const char *value);
00795
00828 typedef int
00829 (*MHD_ContentReaderCallback) (void *cls,
00830 uint64_t pos,
00831 char *buf,
00832 int max);
00833
00840 typedef void (*MHD_ContentReaderFreeCallback) (void *cls);
00841
00861 typedef int
00862 (*MHD_PostDataIterator) (void *cls,
00863 enum MHD_ValueKind kind,
00864 const char *key,
00865 const char *filename,
00866 const char *content_type,
00867 const char *transfer_encoding,
00868 const char *data, uint64_t off, size_t size);
00869
00870
00871
00888 struct MHD_Daemon *MHD_start_daemon_va (unsigned int options,
00889 unsigned short port,
00890 MHD_AcceptPolicyCallback apc,
00891 void *apc_cls,
00892 MHD_AccessHandlerCallback dh,
00893 void *dh_cls, va_list ap);
00894
00910 struct MHD_Daemon *MHD_start_daemon (unsigned int flags,
00911 unsigned short port,
00912 MHD_AcceptPolicyCallback apc,
00913 void *apc_cls,
00914 MHD_AccessHandlerCallback dh,
00915 void *dh_cls, ...);
00916
00922 void MHD_stop_daemon (struct MHD_Daemon *daemon);
00923
00924
00938 int
00939 MHD_get_fdset (struct MHD_Daemon *daemon,
00940 fd_set * read_fd_set,
00941 fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd);
00942
00955 int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
00956
00957
00969 int MHD_run (struct MHD_Daemon *daemon);
00970
00971
00972
00973
00984 int
00985 MHD_get_connection_values (struct MHD_Connection *connection,
00986 enum MHD_ValueKind kind,
00987 MHD_KeyValueIterator iterator, void *iterator_cls);
00988
01018 int
01019 MHD_set_connection_value (struct MHD_Connection *connection,
01020 enum MHD_ValueKind kind,
01021 const char *key, const char *value);
01022
01038 void MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
01039
01049 const char *MHD_lookup_connection_value (struct MHD_Connection *connection,
01050 enum MHD_ValueKind kind,
01051 const char *key);
01052
01063 int
01064 MHD_queue_response (struct MHD_Connection *connection,
01065 unsigned int status_code, struct MHD_Response *response);
01066
01067
01068
01069
01085 struct MHD_Response *MHD_create_response_from_callback (uint64_t size,
01086 size_t block_size,
01087 MHD_ContentReaderCallback
01088 crc, void *crc_cls,
01089 MHD_ContentReaderFreeCallback
01090 crfc);
01091
01104 struct MHD_Response *MHD_create_response_from_data (size_t size,
01105 void *data,
01106 int must_free,
01107 int must_copy);
01108
01117 void MHD_destroy_response (struct MHD_Response *response);
01118
01128 int
01129 MHD_add_response_header (struct MHD_Response *response,
01130 const char *header, const char *content);
01131
01140 int
01141 MHD_del_response_header (struct MHD_Response *response,
01142 const char *header, const char *content);
01143
01153 int
01154 MHD_get_response_headers (struct MHD_Response *response,
01155 MHD_KeyValueIterator iterator, void *iterator_cls);
01156
01157
01165 const char *MHD_get_response_header (struct MHD_Response *response,
01166 const char *key);
01167
01168
01169
01170
01194 struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection
01195 *connection,
01196 size_t buffer_size,
01197 MHD_PostDataIterator
01198 iter, void *cls);
01199
01214 int
01215 MHD_post_process (struct MHD_PostProcessor *pp,
01216 const char *post_data, size_t post_data_len);
01217
01227 int MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
01228
01229
01230
01231
01232
01233
01237 union MHD_ConnectionInfo
01238 {
01239 enum MHD_GNUTLS_CipherAlgorithm cipher_algorithm;
01240 enum MHD_GNUTLS_Protocol protocol;
01244 struct sockaddr_in * client_addr;
01245 };
01246
01256 const union MHD_ConnectionInfo *MHD_get_connection_info (struct MHD_Connection
01257 *connection,
01258 enum
01259 MHD_ConnectionInfoType
01260 infoType, ...);
01261
01262
01266 union MHD_DaemonInfo
01267 {
01271 size_t key_size;
01272
01276 size_t mac_key_size;
01277
01281 int listen_fd;
01282 };
01283
01294 const union MHD_DaemonInfo *MHD_get_daemon_info (struct MHD_Daemon *daemon,
01295 enum MHD_DaemonInfoType
01296 infoType, ...);
01297
01303 const char* MHD_get_version(void);
01304
01305 #if 0
01306 {
01307 #endif
01308 #ifdef __cplusplus
01309 }
01310 #endif
01311
01312 #endif