72 #ifndef MHD_MICROHTTPD_H
73 #define MHD_MICROHTTPD_H
93 #ifndef MHD_PLATFORM_H
100 #include <sys/time.h>
101 #include <sys/types.h>
102 #include <sys/socket.h>
109 #define MHD_VERSION 0x00092100
124 #define MHD_INVALID_NONCE -1
131 #define MHD_SIZE_UNKNOWN UINT64_MAX
133 #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
137 #define MHD_CONTENT_READER_END_OF_STREAM SIZE_MAX
138 #define MHD_CONTENT_READER_END_WITH_ERROR (SIZE_MAX - 1)
140 #define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL)
141 #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1)
149 #ifndef MHD_LONG_LONG
153 #define MHD_LONG_LONG long long
154 #define MHD_UNSIGNED_LONG_LONG unsigned long long
160 #ifndef MHD_LONG_LONG_PRINTF
164 #define MHD_LONG_LONG_PRINTF "ll"
165 #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu"
172 #define MHD_HTTP_CONTINUE 100
173 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
174 #define MHD_HTTP_PROCESSING 102
176 #define MHD_HTTP_OK 200
177 #define MHD_HTTP_CREATED 201
178 #define MHD_HTTP_ACCEPTED 202
179 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
180 #define MHD_HTTP_NO_CONTENT 204
181 #define MHD_HTTP_RESET_CONTENT 205
182 #define MHD_HTTP_PARTIAL_CONTENT 206
183 #define MHD_HTTP_MULTI_STATUS 207
185 #define MHD_HTTP_MULTIPLE_CHOICES 300
186 #define MHD_HTTP_MOVED_PERMANENTLY 301
187 #define MHD_HTTP_FOUND 302
188 #define MHD_HTTP_SEE_OTHER 303
189 #define MHD_HTTP_NOT_MODIFIED 304
190 #define MHD_HTTP_USE_PROXY 305
191 #define MHD_HTTP_SWITCH_PROXY 306
192 #define MHD_HTTP_TEMPORARY_REDIRECT 307
194 #define MHD_HTTP_BAD_REQUEST 400
195 #define MHD_HTTP_UNAUTHORIZED 401
196 #define MHD_HTTP_PAYMENT_REQUIRED 402
197 #define MHD_HTTP_FORBIDDEN 403
198 #define MHD_HTTP_NOT_FOUND 404
199 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
200 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
201 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
202 #define MHD_HTTP_REQUEST_TIMEOUT 408
203 #define MHD_HTTP_CONFLICT 409
204 #define MHD_HTTP_GONE 410
205 #define MHD_HTTP_LENGTH_REQUIRED 411
206 #define MHD_HTTP_PRECONDITION_FAILED 412
207 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
208 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
209 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
210 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
211 #define MHD_HTTP_EXPECTATION_FAILED 417
212 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
213 #define MHD_HTTP_LOCKED 423
214 #define MHD_HTTP_FAILED_DEPENDENCY 424
215 #define MHD_HTTP_UNORDERED_COLLECTION 425
216 #define MHD_HTTP_UPGRADE_REQUIRED 426
217 #define MHD_HTTP_NO_RESPONSE 444
218 #define MHD_HTTP_RETRY_WITH 449
219 #define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS 450
220 #define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451
222 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
223 #define MHD_HTTP_NOT_IMPLEMENTED 501
224 #define MHD_HTTP_BAD_GATEWAY 502
225 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
226 #define MHD_HTTP_GATEWAY_TIMEOUT 504
227 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
228 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
229 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
230 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
231 #define MHD_HTTP_NOT_EXTENDED 510
238 #define MHD_ICY_FLAG ((uint32_t)(1 << 31))
241 #define MHD_HTTP_HEADER_ACCEPT "Accept"
242 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
243 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
244 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
245 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
246 #define MHD_HTTP_HEADER_AGE "Age"
247 #define MHD_HTTP_HEADER_ALLOW "Allow"
248 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
249 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
250 #define MHD_HTTP_HEADER_CONNECTION "Connection"
251 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
252 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
253 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
254 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
255 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
256 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
257 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
258 #define MHD_HTTP_HEADER_COOKIE "Cookie"
259 #define MHD_HTTP_HEADER_DATE "Date"
260 #define MHD_HTTP_HEADER_ETAG "ETag"
261 #define MHD_HTTP_HEADER_EXPECT "Expect"
262 #define MHD_HTTP_HEADER_EXPIRES "Expires"
263 #define MHD_HTTP_HEADER_FROM "From"
264 #define MHD_HTTP_HEADER_HOST "Host"
265 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
266 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
267 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
268 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
269 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
270 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
271 #define MHD_HTTP_HEADER_LOCATION "Location"
272 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
273 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
274 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
275 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
276 #define MHD_HTTP_HEADER_RANGE "Range"
278 #define MHD_HTTP_HEADER_REFERER "Referer"
279 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
280 #define MHD_HTTP_HEADER_SERVER "Server"
281 #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie"
282 #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2"
283 #define MHD_HTTP_HEADER_TE "TE"
284 #define MHD_HTTP_HEADER_TRAILER "Trailer"
285 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
286 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
287 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
288 #define MHD_HTTP_HEADER_VARY "Vary"
289 #define MHD_HTTP_HEADER_VIA "Via"
290 #define MHD_HTTP_HEADER_WARNING "Warning"
291 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
297 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
298 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
303 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
304 #define MHD_HTTP_METHOD_DELETE "DELETE"
305 #define MHD_HTTP_METHOD_GET "GET"
306 #define MHD_HTTP_METHOD_HEAD "HEAD"
307 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
308 #define MHD_HTTP_METHOD_POST "POST"
309 #define MHD_HTTP_METHOD_PUT "PUT"
310 #define MHD_HTTP_METHOD_TRACE "TRACE"
316 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
317 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
840 struct MHD_Connection;
850 struct MHD_PostProcessor;
877 const struct sockaddr * addr,
918 struct MHD_Connection * connection,
922 const char *upload_data,
923 size_t *upload_data_size,
940 struct MHD_Connection *connection,
958 const char *key,
const char *value);
1048 const char *filename,
1049 const char *content_type,
1050 const char *transfer_encoding,
1154 const struct sockaddr *addr,
1173 fd_set *read_fd_set,
1174 fd_set *write_fd_set,
1175 fd_set *except_fd_set,
1216 MHD_run (
struct MHD_Daemon *daemon);
1239 const fd_set *read_fd_set,
1240 const fd_set *write_fd_set,
1241 const fd_set *except_fd_set);
1344 unsigned int status_code,
1345 struct MHD_Response *response);
1365 struct MHD_Response *
1385 struct MHD_Response *
1432 struct MHD_Response *
1448 struct MHD_Response *
1468 struct MHD_Response *
1480 enum MHD_UpgradeEventMask
1487 MHD_UPGRADE_EVENT_TERMINATE = 0,
1493 MHD_UPGRADE_EVENT_READ = 1,
1499 MHD_UPGRADE_EVENT_WRITE = 2,
1508 MHD_UPGRADE_EVENT_EXTERNAL = 4,
1517 MHD_UPGRADE_EVENT_CORK = 8
1565 typedef enum MHD_UpgradeEventMask (*MHD_UpgradeHandler)(
void *cls,
1566 struct MHD_Connection *connection,
1568 size_t *data_in_size,
1569 const char *data_in,
1570 size_t *data_out_size,
1603 struct MHD_Response *
1604 MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler,
1605 void *upgrade_handler_cls);
1630 const char *header,
const char *content);
1643 const char *footer,
const char *content);
1656 const char *header,
const char *content);
1710 struct MHD_PostProcessor *
1731 const char *post_data,
size_t post_data_len);
1753 #define MHD_INVALID_NONCE -1
1782 const char *username,
1783 const char *password,
1784 unsigned int nonce_timeout);
1804 struct MHD_Response *response,
1834 struct MHD_Response *response);