00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00065 #ifndef MHD_MICROHTTPD_H
00066 #define MHD_MICROHTTPD_H
00067
00068 #include <sys/types.h>
00069 #ifndef MINGW
00070 #include <sys/select.h>
00071 #include <sys/socket.h>
00072 #else
00073 #include "plibc.h"
00074 #endif
00075
00076 #ifdef __cplusplus
00077 extern "C"
00078 {
00079 #if 0
00080 }
00081 #endif
00082 #endif
00083
00087 #define MHD_VERSION 0x00030000
00088
00092 #define MHD_YES 1
00093
00094 #define MHD_NO 0
00095
00099 #define MHD_HTTP_CONTINUE 100
00100 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
00101 #define MHD_HTTP_PROCESSING 102
00102
00103 #define MHD_HTTP_OK 200
00104 #define MHD_HTTP_CREATED 201
00105 #define MHD_HTTP_ACCEPTED 202
00106 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
00107 #define MHD_HTTP_NO_CONTENT 204
00108 #define MHD_HTTP_RESET_CONTENT 205
00109 #define MHD_HTTP_PARTIAL_CONTENT 206
00110 #define MHD_HTTP_MULTI_STATUS 207
00111
00112 #define MHD_HTTP_MULTIPLE_CHOICES 300
00113 #define MHD_HTTP_MOVED_PERMANENTLY 301
00114 #define MHD_HTTP_FOUND 302
00115 #define MHD_HTTP_SEE_OTHER 303
00116 #define MHD_HTTP_NOT_MODIFIED 304
00117 #define MHD_HTTP_USE_PROXY 305
00118 #define MHD_HTTP_SWITCH_PROXY 306
00119 #define MHD_HTTP_TEMPORARY_REDIRECT 307
00120
00121 #define MHD_HTTP_BAD_REQUEST 400
00122 #define MHD_HTTP_UNAUTHORIZED 401
00123 #define MHD_HTTP_PAYMENT_REQUIRED 402
00124 #define MHD_HTTP_FORBIDDEN 403
00125 #define MHD_HTTP_NOT_FOUND 404
00126 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
00127 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
00128 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
00129 #define MHD_HTTP_REQUEST_TIMEOUT 408
00130 #define MHD_HTTP_CONFLICT 409
00131 #define MHD_HTTP_GONE 410
00132 #define MHD_HTTP_LENGTH_REQUIRED 411
00133 #define MHD_HTTP_PRECONDITION_FAILED 412
00134 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
00135 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
00136 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
00137 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
00138 #define MHD_HTTP_EXPECTATION_FAILED 417
00139 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
00140 #define MHD_HTTP_LOCKED 423
00141 #define MHD_HTTP_FAILED_DEPENDENCY 424
00142 #define MHD_HTTP_UNORDERED_COLLECTION 425
00143 #define MHD_HTTP_UPGRADE_REQUIRED 426
00144 #define MHD_HTTP_RETRY_WITH 449
00145
00146 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
00147 #define MHD_HTTP_NOT_IMPLEMENTED 501
00148 #define MHD_HTTP_BAD_GATEWAY 502
00149 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
00150 #define MHD_HTTP_GATEWAY_TIMEOUT 504
00151 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
00152 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
00153 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
00154 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
00155 #define MHD_HTTP_NOT_EXTENDED 510
00156
00157
00158 #define MHD_HTTP_HEADER_ACCEPT "Accept"
00159 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
00160 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
00161 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
00162 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
00163 #define MHD_HTTP_HEADER_AGE "Age"
00164 #define MHD_HTTP_HEADER_ALLOW "Allow"
00165 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
00166 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
00167 #define MHD_HTTP_HEADER_CONNECTION "Connection"
00168 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
00169 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
00170 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
00171 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
00172 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
00173 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
00174 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
00175 #define MHD_HTTP_HEADER_DATE "Date"
00176 #define MHD_HTTP_HEADER_ETAG "ETag"
00177 #define MHD_HTTP_HEADER_EXPECT "Expect"
00178 #define MHD_HTTP_HEADER_EXPIRES "Expires"
00179 #define MHD_HTTP_HEADER_FROM "From"
00180 #define MHD_HTTP_HEADER_HOST "Host"
00181 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
00182 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
00183 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
00184 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
00185 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
00186 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
00187 #define MHD_HTTP_HEADER_LOCATION "Location"
00188 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
00189 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
00190 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
00191 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
00192 #define MHD_HTTP_HEADER_RANGE "Range"
00193 #define MHD_HTTP_HEADER_REFERER "Referer"
00194 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
00195 #define MHD_HTTP_HEADER_SERVER "Server"
00196 #define MHD_HTTP_HEADER_TE "TE"
00197 #define MHD_HTTP_HEADER_TRAILER "Trailer"
00198 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
00199 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
00200 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
00201 #define MHD_HTTP_HEADER_VARY "Vary"
00202 #define MHD_HTTP_HEADER_VIA "Via"
00203 #define MHD_HTTP_HEADER_WARNING "Warning"
00204 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
00205
00210 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
00211 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
00212
00216 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
00217 #define MHD_HTTP_METHOD_DELETE "DELETE"
00218 #define MHD_HTTP_METHOD_GET "GET"
00219 #define MHD_HTTP_METHOD_HEAD "HEAD"
00220 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
00221 #define MHD_HTTP_METHOD_POST "POST"
00222 #define MHD_HTTP_METHOD_PUT "PUT"
00223 #define MHD_HTTP_METHOD_TRACE "TRACE"
00224
00229 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
00230 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
00231
00242 enum MHD_FLAG
00243 {
00247 MHD_NO_FLAG = 0,
00248
00254 MHD_USE_DEBUG = 1,
00255
00259 MHD_USE_SSL = 2,
00260
00264 MHD_USE_THREAD_PER_CONNECTION = 4,
00265
00269 MHD_USE_SELECT_INTERNALLY = 8,
00270
00275 MHD_USE_IPv6 = 16,
00276
00286 MHD_USE_PEDANTIC_CHECKS = 32,
00287
00288 };
00289
00294 enum MHD_OPTION
00295 {
00296
00301 MHD_OPTION_END = 0,
00302
00307 MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1,
00308
00313 MHD_OPTION_CONNECTION_LIMIT = 2,
00314
00320 MHD_OPTION_CONNECTION_TIMEOUT = 3,
00321
00334 MHD_OPTION_NOTIFY_COMPLETED = 4,
00335
00346 MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5,
00347
00348 };
00349
00354 enum MHD_ValueKind
00355 {
00356
00360 MHD_RESPONSE_HEADER_KIND = 0,
00361
00365 MHD_HEADER_KIND = 1,
00366
00371 MHD_COOKIE_KIND = 2,
00372
00381 MHD_POSTDATA_KIND = 4,
00382
00386 MHD_GET_ARGUMENT_KIND = 8,
00387
00391 MHD_FOOTER_KIND = 16,
00392
00393 };
00394
00399 enum MHD_RequestTerminationCode
00400 {
00401
00405 MHD_REQUEST_TERMINATED_COMPLETED_OK = 0,
00406
00412 MHD_REQUEST_TERMINATED_WITH_ERROR = 1,
00413
00419 MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2,
00420
00425 MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3,
00426
00427 };
00428
00432 struct MHD_Daemon;
00433
00440 struct MHD_Connection;
00441
00445 struct MHD_Response;
00446
00450 struct MHD_PostProcessor;
00451
00460 typedef int
00461 (*MHD_AcceptPolicyCallback) (void *cls,
00462 const struct sockaddr * addr,
00463 socklen_t addrlen);
00464
00500 typedef int
00501 (*MHD_AccessHandlerCallback) (void *cls,
00502 struct MHD_Connection * connection,
00503 const char *url,
00504 const char *method,
00505 const char *version,
00506 const char *upload_data,
00507 unsigned int *upload_data_size,
00508 void **con_cls);
00509
00521 typedef void
00522 (*MHD_RequestCompletedCallback) (void *cls,
00523 struct MHD_Connection * connection,
00524 void **con_cls,
00525 enum MHD_RequestTerminationCode toe);
00526
00537 typedef int
00538 (*MHD_KeyValueIterator) (void *cls,
00539 enum MHD_ValueKind kind,
00540 const char *key, const char *value);
00541
00574 typedef int
00575 (*MHD_ContentReaderCallback) (void *cls, size_t pos, char *buf, int max);
00576
00583 typedef void (*MHD_ContentReaderFreeCallback) (void *cls);
00584
00604 typedef int
00605 (*MHD_PostDataIterator) (void *cls,
00606 enum MHD_ValueKind kind,
00607 const char *key,
00608 const char *filename,
00609 const char *content_type,
00610 const char *transfer_encoding,
00611 const char *data, size_t off, size_t size);
00612
00628 struct MHD_Daemon *MHD_start_daemon (unsigned int flags,
00629 unsigned short port,
00630 MHD_AcceptPolicyCallback apc,
00631 void *apc_cls,
00632 MHD_AccessHandlerCallback dh,
00633 void *dh_cls, ...);
00634
00635
00636
00640 void MHD_stop_daemon (struct MHD_Daemon *daemon);
00641
00642
00650 int
00651 MHD_get_fdset (struct MHD_Daemon *daemon,
00652 fd_set * read_fd_set,
00653 fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd);
00654
00666 int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
00667
00668
00679 int MHD_run (struct MHD_Daemon *daemon);
00680
00689 int
00690 MHD_get_connection_values (struct MHD_Connection *connection,
00691 enum MHD_ValueKind kind,
00692 MHD_KeyValueIterator iterator, void *iterator_cls);
00693
00701 const char *MHD_lookup_connection_value (struct MHD_Connection *connection,
00702 enum MHD_ValueKind kind,
00703 const char *key);
00704
00715 int
00716 MHD_queue_response (struct MHD_Connection *connection,
00717 unsigned int status_code, struct MHD_Response *response);
00718
00719
00735 struct MHD_Response *MHD_create_response_from_callback (size_t size,
00736 unsigned int
00737 block_size,
00738 MHD_ContentReaderCallback
00739 crc, void *crc_cls,
00740 MHD_ContentReaderFreeCallback
00741 crfc);
00742
00755 struct MHD_Response *MHD_create_response_from_data (size_t size,
00756 void *data,
00757 int must_free,
00758 int must_copy);
00759
00766 void MHD_destroy_response (struct MHD_Response *response);
00767
00773 int
00774 MHD_add_response_header (struct MHD_Response *response,
00775 const char *header, const char *content);
00776
00782 int
00783 MHD_del_response_header (struct MHD_Response *response,
00784 const char *header, const char *content);
00785
00794 int
00795 MHD_get_response_headers (struct MHD_Response *response,
00796 MHD_KeyValueIterator iterator, void *iterator_cls);
00797
00798
00805 const char *MHD_get_response_header (struct MHD_Response *response,
00806 const char *key);
00807
00808
00828 struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection
00829 *connection,
00830 unsigned int buffer_size,
00831 MHD_PostDataIterator
00832 iter, void *cls);
00833
00848 int
00849 MHD_post_process (struct MHD_PostProcessor *pp,
00850 const char *post_data, unsigned int post_data_len);
00851
00860 int MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
00861
00862
00863 #if 0
00864 {
00865 #endif
00866 #ifdef __cplusplus
00867 }
00868 #endif
00869
00870 #endif