GNU libmicrohttpd  0.9.29
microhttpd.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  Copyright (C) 2006-2016 Christian Grothoff (and other contributing authors)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
79 #ifndef MHD_MICROHTTPD_H
80 #define MHD_MICROHTTPD_H
81 
82 #ifdef __cplusplus
83 extern "C"
84 {
85 #if 0 /* keep Emacsens' auto-indent happy */
86 }
87 #endif
88 #endif
89 
90 /* While we generally would like users to use a configure-driven
91  build process which detects which headers are present and
92  hence works on any platform, we use "standard" includes here
93  to build out-of-the-box for beginning users on common systems.
94 
95  If generic headers don't work on your platform, include headers
96  which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
97  'uint16_t', 'uint32_t', 'uint64_t', 'off_t', 'struct sockaddr',
98  'socklen_t', 'fd_set' and "#define MHD_PLATFORM_H" before
99  including "microhttpd.h". Then the following "standard"
100  includes won't be used (which might be a good idea, especially
101  on platforms where they do not exist).
102  */
103 #ifndef MHD_PLATFORM_H
104 #include <stdarg.h>
105 #include <stdint.h>
106 #include <sys/types.h>
107 #if defined(_WIN32) && !defined(__CYGWIN__)
108 #include <ws2tcpip.h>
109 #if defined(_MSC_FULL_VER) && !defined (_SSIZE_T_DEFINED)
110 #define _SSIZE_T_DEFINED
111 typedef intptr_t ssize_t;
112 #endif /* !_SSIZE_T_DEFINED */
113 #else
114 #include <unistd.h>
115 #include <sys/time.h>
116 #include <sys/socket.h>
117 #endif
118 #endif
119 
120 #if defined(__CYGWIN__) && !defined(_SYS_TYPES_FD_SET)
121 /* Do not define __USE_W32_SOCKETS under Cygwin! */
122 #error Cygwin with winsock fd_set is not supported
123 #endif
124 
129 #define MHD_VERSION 0x00095102
130 
134 #define MHD_YES 1
135 
139 #define MHD_NO 0
140 
144 #define MHD_INVALID_NONCE -1
145 
150 #ifdef UINT64_MAX
151 #define MHD_SIZE_UNKNOWN UINT64_MAX
152 #else
153 #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
154 #endif
155 
156 #ifdef SIZE_MAX
157 #define MHD_CONTENT_READER_END_OF_STREAM SIZE_MAX
158 #define MHD_CONTENT_READER_END_WITH_ERROR (SIZE_MAX - 1)
159 #else
160 #define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL)
161 #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1)
162 #endif
163 
164 #ifndef _MHD_EXTERN
165 #if defined(_WIN32) && defined(MHD_W32LIB)
166 #define _MHD_EXTERN extern
167 #elif defined (_WIN32) && defined(MHD_W32DLL)
168 /* Define MHD_W32DLL when using MHD as W32 .DLL to speed up linker a little */
169 #define _MHD_EXTERN __declspec(dllimport)
170 #else
171 #define _MHD_EXTERN extern
172 #endif
173 #endif
174 
175 #ifndef MHD_SOCKET_DEFINED
176 
179 #if !defined(_WIN32) || defined(_SYS_TYPES_FD_SET)
180 #define MHD_POSIX_SOCKETS 1
181 typedef int MHD_socket;
182 #define MHD_INVALID_SOCKET (-1)
183 #else /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
184 #define MHD_WINSOCK_SOCKETS 1
185 #include <winsock2.h>
186 typedef SOCKET MHD_socket;
187 #define MHD_INVALID_SOCKET (INVALID_SOCKET)
188 #endif /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
189 #define MHD_SOCKET_DEFINED 1
190 #endif /* MHD_SOCKET_DEFINED */
191 
195 #ifdef MHD_NO_DEPRECATION
196 #define _MHD_DEPR_MACRO(msg)
197 #define _MHD_NO_DEPR_IN_MACRO 1
198 #define _MHD_DEPR_IN_MACRO(msg)
199 #define _MHD_NO_DEPR_FUNC 1
200 #define _MHD_DEPR_FUNC(msg)
201 #endif /* MHD_NO_DEPRECATION */
202 
203 #ifndef _MHD_DEPR_MACRO
204 #if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1500
205 /* VS 2008 or later */
206 /* Stringify macros */
207 #define _MHD_INSTRMACRO(a) #a
208 #define _MHD_STRMACRO(a) _MHD_INSTRMACRO(a)
209 /* deprecation message */
210 #define _MHD_DEPR_MACRO(msg) __pragma(message(__FILE__ "(" _MHD_STRMACRO(__LINE__)"): warning: " msg))
211 #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg)
212 #elif defined(__clang__) || defined (__GNUC_PATCHLEVEL__)
213 /* clang or GCC since 3.0 */
214 #define _MHD_GCC_PRAG(x) _Pragma (#x)
215 #if __clang_major__+0 >= 5 || \
216  (!defined(__apple_build_version__) && (__clang_major__+0 > 3 || (__clang_major__+0 == 3 && __clang_minor__ >= 3))) || \
217  __GNUC__+0 > 4 || (__GNUC__+0 == 4 && __GNUC_MINOR__+0 >= 8)
218 /* clang >= 3.3 (or XCode's clang >= 5.0) or
219  GCC >= 4.8 */
220 #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(GCC warning msg)
221 #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg)
222 #else /* older clang or GCC */
223 /* clang < 3.3, XCode's clang < 5.0, 3.0 <= GCC < 4.8 */
224 #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(message msg)
225 #if (__clang_major__+0 > 2 || (__clang_major__+0 == 2 && __clang_minor__ >= 9)) /* FIXME: clang >= 2.9, earlier versions not tested */
226 /* clang handles inline pragmas better than GCC */
227 #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg)
228 #endif /* clang >= 2.9 */
229 #endif /* older clang or GCC */
230 /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */
231 #endif /* clang || GCC >= 3.0 */
232 #endif /* !_MHD_DEPR_MACRO */
233 
234 #ifndef _MHD_DEPR_MACRO
235 #define _MHD_DEPR_MACRO(msg)
236 #endif /* !_MHD_DEPR_MACRO */
237 
238 #ifndef _MHD_DEPR_IN_MACRO
239 #define _MHD_NO_DEPR_IN_MACRO 1
240 #define _MHD_DEPR_IN_MACRO(msg)
241 #endif /* !_MHD_DEPR_IN_MACRO */
242 
243 #ifndef _MHD_DEPR_FUNC
244 #if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1400
245 /* VS 2005 or later */
246 #define _MHD_DEPR_FUNC(msg) __declspec(deprecated(msg))
247 #elif defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1310
248 /* VS .NET 2003 deprecation do not support custom messages */
249 #define _MHD_DEPR_FUNC(msg) __declspec(deprecated)
250 #elif (__GNUC__+0 >= 5) || (defined (__clang__) && \
251  (__clang_major__+0 > 2 || (__clang_major__+0 == 2 && __clang_minor__ >= 9))) /* FIXME: earlier versions not tested */
252 /* GCC >= 5.0 or clang >= 2.9 */
253 #define _MHD_DEPR_FUNC(msg) __attribute__((deprecated(msg)))
254 #elif defined (__clang__) || __GNUC__+0 > 3 || (__GNUC__+0 == 3 && __GNUC_MINOR__+0 >= 1)
255 /* 3.1 <= GCC < 5.0 or clang < 2.9 */
256 /* old GCC-style deprecation do not support custom messages */
257 #define _MHD_DEPR_FUNC(msg) __attribute__((__deprecated__))
258 /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */
259 #endif /* clang < 2.9 || GCC >= 3.1 */
260 #endif /* !_MHD_DEPR_FUNC */
261 
262 #ifndef _MHD_DEPR_FUNC
263 #define _MHD_NO_DEPR_FUNC 1
264 #define _MHD_DEPR_FUNC(msg)
265 #endif /* !_MHD_DEPR_FUNC */
266 
272 #ifndef MHD_LONG_LONG
273 
276 #define MHD_LONG_LONG long long
277 #define MHD_UNSIGNED_LONG_LONG unsigned long long
278 #else /* MHD_LONG_LONG */
279 _MHD_DEPR_MACRO("Macro MHD_LONG_LONG is deprecated, use MHD_UNSIGNED_LONG_LONG")
280 #endif
281 
285 #ifndef MHD_LONG_LONG_PRINTF
286 
289 #define MHD_LONG_LONG_PRINTF "ll"
290 #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu"
291 #else /* MHD_LONG_LONG_PRINTF */
292 _MHD_DEPR_MACRO("Macro MHD_LONG_LONG_PRINTF is deprecated, use MHD_UNSIGNED_LONG_LONG_PRINTF")
293 #endif
294 
295 
301 #define MHD_HTTP_CONTINUE 100
302 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
303 #define MHD_HTTP_PROCESSING 102
304 
305 #define MHD_HTTP_OK 200
306 #define MHD_HTTP_CREATED 201
307 #define MHD_HTTP_ACCEPTED 202
308 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
309 #define MHD_HTTP_NO_CONTENT 204
310 #define MHD_HTTP_RESET_CONTENT 205
311 #define MHD_HTTP_PARTIAL_CONTENT 206
312 #define MHD_HTTP_MULTI_STATUS 207
313 
314 #define MHD_HTTP_MULTIPLE_CHOICES 300
315 #define MHD_HTTP_MOVED_PERMANENTLY 301
316 #define MHD_HTTP_FOUND 302
317 #define MHD_HTTP_SEE_OTHER 303
318 #define MHD_HTTP_NOT_MODIFIED 304
319 #define MHD_HTTP_USE_PROXY 305
320 #define MHD_HTTP_SWITCH_PROXY 306
321 #define MHD_HTTP_TEMPORARY_REDIRECT 307
322 #define MHD_HTTP_PERMANENT_REDIRECT 308
323 
324 #define MHD_HTTP_BAD_REQUEST 400
325 #define MHD_HTTP_UNAUTHORIZED 401
326 #define MHD_HTTP_PAYMENT_REQUIRED 402
327 #define MHD_HTTP_FORBIDDEN 403
328 #define MHD_HTTP_NOT_FOUND 404
329 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
330 #define MHD_HTTP_NOT_ACCEPTABLE 406
331 
332 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE \
333  _MHD_DEPR_IN_MACRO("Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE") 406
334 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
335 #define MHD_HTTP_REQUEST_TIMEOUT 408
336 #define MHD_HTTP_CONFLICT 409
337 #define MHD_HTTP_GONE 410
338 #define MHD_HTTP_LENGTH_REQUIRED 411
339 #define MHD_HTTP_PRECONDITION_FAILED 412
340 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
341 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
342 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
343 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
344 #define MHD_HTTP_EXPECTATION_FAILED 417
345 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
346 #define MHD_HTTP_LOCKED 423
347 #define MHD_HTTP_FAILED_DEPENDENCY 424
348 #define MHD_HTTP_UNORDERED_COLLECTION 425
349 #define MHD_HTTP_UPGRADE_REQUIRED 426
350 #define MHD_HTTP_NO_RESPONSE 444
351 #define MHD_HTTP_RETRY_WITH 449
352 #define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS 450
353 #define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451
354 
355 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
356 #define MHD_HTTP_NOT_IMPLEMENTED 501
357 #define MHD_HTTP_BAD_GATEWAY 502
358 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
359 #define MHD_HTTP_GATEWAY_TIMEOUT 504
360 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
361 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
362 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
363 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
364 #define MHD_HTTP_NOT_EXTENDED 510
365  /* end of group httpcode */
367 
374 _MHD_EXTERN const char *
375 MHD_get_reason_phrase_for (unsigned int code);
376 
377 
384 #define MHD_ICY_FLAG ((uint32_t)(((uint32_t)1) << 31))
385 
391 /* See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html */
392 #define MHD_HTTP_HEADER_ACCEPT "Accept"
393 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
394 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
395 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
396 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
397 #define MHD_HTTP_HEADER_AGE "Age"
398 #define MHD_HTTP_HEADER_ALLOW "Allow"
399 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
400 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
401 #define MHD_HTTP_HEADER_CONNECTION "Connection"
402 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
403 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
404 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
405 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
406 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
407 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
408 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
409 #define MHD_HTTP_HEADER_COOKIE "Cookie"
410 #define MHD_HTTP_HEADER_DATE "Date"
411 #define MHD_HTTP_HEADER_ETAG "ETag"
412 #define MHD_HTTP_HEADER_EXPECT "Expect"
413 #define MHD_HTTP_HEADER_EXPIRES "Expires"
414 #define MHD_HTTP_HEADER_FROM "From"
415 #define MHD_HTTP_HEADER_HOST "Host"
416 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
417 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
418 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
419 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
420 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
421 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
422 #define MHD_HTTP_HEADER_LOCATION "Location"
423 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
424 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
425 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
426 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
427 #define MHD_HTTP_HEADER_RANGE "Range"
428 /* This is not a typo, see HTTP spec */
429 #define MHD_HTTP_HEADER_REFERER "Referer"
430 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
431 #define MHD_HTTP_HEADER_SERVER "Server"
432 #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie"
433 #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2"
434 #define MHD_HTTP_HEADER_TE "TE"
435 #define MHD_HTTP_HEADER_TRAILER "Trailer"
436 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
437 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
438 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
439 #define MHD_HTTP_HEADER_VARY "Vary"
440 #define MHD_HTTP_HEADER_VIA "Via"
441 #define MHD_HTTP_HEADER_WARNING "Warning"
442 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
443 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN "Access-Control-Allow-Origin"
444 #define MHD_HTTP_HEADER_CONTENT_DISPOSITION "Content-Disposition"
445  /* end of group headers */
447 
454 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
455 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
456  /* end of group versions */
458 
464 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
465 #define MHD_HTTP_METHOD_DELETE "DELETE"
466 #define MHD_HTTP_METHOD_GET "GET"
467 #define MHD_HTTP_METHOD_HEAD "HEAD"
468 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
469 #define MHD_HTTP_METHOD_POST "POST"
470 #define MHD_HTTP_METHOD_PUT "PUT"
471 #define MHD_HTTP_METHOD_PATCH "PATCH"
472 #define MHD_HTTP_METHOD_TRACE "TRACE"
473  /* end of group methods */
475 
481 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
482 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
483  /* end of group postenc */
485 
486 
491 struct MHD_Daemon;
492 
501 struct MHD_Connection;
502 
507 struct MHD_Response;
508 
513 struct MHD_PostProcessor;
514 
515 
528 {
533 
539 
545 
546 #if 0
547  /* let's do this later once versions that define MHD_USE_TLS a more widely deployed. */
549 #define MHD_USE_SSL \
550  _MHD_DEPR_IN_MACRO("Value MHD_USE_SSL is deprecated, use MHD_USE_TLS") \
551  MHD_USE_TLS
552 #endif
553 
558 
563 
572 
583 
592 
597 
605 
614 
623 
625 #define MHD_USE_EPOLL_LINUX_ONLY \
626  _MHD_DEPR_IN_MACRO("Value MHD_USE_EPOLL_LINUX_ONLY is deprecated, use MHD_USE_EPOLL") \
627  MHD_USE_EPOLL
628 
635 
637 #define MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY \
638  _MHD_DEPR_IN_MACRO("Value MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY is deprecated, use MHD_USE_EPOLL_INTERNALLY") \
639  MHD_USE_EPOLL_INTERNALLY
640 
654  MHD_USE_ITC = 1024,
655 
657 #define MHD_USE_PIPE_FOR_SHUTDOWN \
658  _MHD_DEPR_IN_MACRO("Value MHD_USE_PIPE_FOR_SHUTDOWN is deprecated, use MHD_USE_ITC") \
659  MHD_USE_ITC
660 
665 
674 
680 
687 
697 
698 };
699 
700 
709 typedef void
710 (*MHD_LogCallback)(void *cls,
711  const char *fm,
712  va_list ap);
713 
714 
721 {
722 
728 
737 
743 
750 
764 
776 
784 
812 
820 
828 
835 
841 
849 
862 
872 
893 
913 
924 
931 
937 
944 
950 
966 
975 
982 
991 
1000 
1011 
1019 };
1020 
1021 
1026 {
1032 
1038  intptr_t value;
1039 
1044  void *ptr_value;
1045 
1046 };
1047 
1048 
1054 {
1055 
1060 
1065 
1071 
1081 
1086 
1091 };
1092 
1093 
1100 {
1101 
1107 
1115 
1123 
1130 
1140 
1148 
1149 };
1150 
1151 
1158 {
1159 
1165 
1171 
1172 };
1173 
1174 
1179 {
1180 
1184  int /* enum gnutls_cipher_algorithm */ cipher_algorithm;
1185 
1189  int /* enum gnutls_protocol */ protocol;
1190 
1194  int /* MHD_YES or MHD_NO */ suspended;
1195 
1200 
1204  void * /* gnutls_session_t */ tls_session;
1205 
1209  void * /* gnutls_x509_crt_t */ client_cert;
1210 
1214  struct sockaddr *client_addr;
1215 
1221 
1227 };
1228 
1229 
1236 {
1243 
1250 
1259 
1265 
1273 
1279 
1286 
1296 
1302 };
1303 
1304 
1310 {
1315 
1320 
1326 
1333 
1339 };
1340 
1341 
1352 typedef void
1353 (*MHD_PanicCallback) (void *cls,
1354  const char *file,
1355  unsigned int line,
1356  const char *reason);
1357 
1366 typedef int
1368  const struct sockaddr *addr,
1369  socklen_t addrlen);
1370 
1371 
1411 typedef int
1413  struct MHD_Connection *connection,
1414  const char *url,
1415  const char *method,
1416  const char *version,
1417  const char *upload_data,
1418  size_t *upload_data_size,
1419  void **con_cls);
1420 
1421 
1434 typedef void
1436  struct MHD_Connection *connection,
1437  void **con_cls,
1438  enum MHD_RequestTerminationCode toe);
1439 
1459 typedef void
1461  struct MHD_Connection *connection,
1462  void **socket_context,
1464 
1465 
1481 typedef int
1482 (*MHD_KeyValueIterator) (void *cls,
1483  enum MHD_ValueKind kind,
1484  const char *key,
1485  const char *value);
1486 
1487 
1532 typedef ssize_t
1534  uint64_t pos,
1535  char *buf,
1536  size_t max);
1537 
1538 
1548 typedef void
1550 
1551 
1571 typedef int
1572 (*MHD_PostDataIterator) (void *cls,
1573  enum MHD_ValueKind kind,
1574  const char *key,
1575  const char *filename,
1576  const char *content_type,
1577  const char *transfer_encoding,
1578  const char *data,
1579  uint64_t off,
1580  size_t size);
1581 
1582 /* **************** Daemon handling functions ***************** */
1583 
1601 _MHD_EXTERN struct MHD_Daemon *
1602 MHD_start_daemon_va (unsigned int flags,
1603  uint16_t port,
1605  MHD_AccessHandlerCallback dh, void *dh_cls,
1606  va_list ap);
1607 
1608 
1625 _MHD_EXTERN struct MHD_Daemon *
1626 MHD_start_daemon (unsigned int flags,
1627  uint16_t port,
1629  MHD_AccessHandlerCallback dh, void *dh_cls,
1630  ...);
1631 
1632 
1653 MHD_quiesce_daemon (struct MHD_Daemon *daemon);
1654 
1655 
1662 _MHD_EXTERN void
1663 MHD_stop_daemon (struct MHD_Daemon *daemon);
1664 
1665 
1695 _MHD_EXTERN int
1696 MHD_add_connection (struct MHD_Daemon *daemon,
1697  MHD_socket client_socket,
1698  const struct sockaddr *addr,
1699  socklen_t addrlen);
1700 
1701 
1721 _MHD_EXTERN int
1722 MHD_get_fdset (struct MHD_Daemon *daemon,
1723  fd_set *read_fd_set,
1724  fd_set *write_fd_set,
1725  fd_set *except_fd_set,
1726  MHD_socket *max_fd);
1727 
1728 
1750 _MHD_EXTERN int
1751 MHD_get_fdset2 (struct MHD_Daemon *daemon,
1752  fd_set *read_fd_set,
1753  fd_set *write_fd_set,
1754  fd_set *except_fd_set,
1755  MHD_socket *max_fd,
1756  unsigned int fd_setsize);
1757 
1758 
1778 #define MHD_get_fdset(daemon,read_fd_set,write_fd_set,except_fd_set,max_fd) \
1779  MHD_get_fdset2((daemon),(read_fd_set),(write_fd_set),(except_fd_set),(max_fd),FD_SETSIZE)
1780 
1781 
1796 _MHD_EXTERN int
1797 MHD_get_timeout (struct MHD_Daemon *daemon,
1798  MHD_UNSIGNED_LONG_LONG *timeout);
1799 
1800 
1820 _MHD_EXTERN int
1821 MHD_run (struct MHD_Daemon *daemon);
1822 
1823 
1843 _MHD_EXTERN int
1844 MHD_run_from_select (struct MHD_Daemon *daemon,
1845  const fd_set *read_fd_set,
1846  const fd_set *write_fd_set,
1847  const fd_set *except_fd_set);
1848 
1849 
1850 
1851 
1852 /* **************** Connection handling functions ***************** */
1853 
1865 _MHD_EXTERN int
1866 MHD_get_connection_values (struct MHD_Connection *connection,
1867  enum MHD_ValueKind kind,
1868  MHD_KeyValueIterator iterator,
1869  void *iterator_cls);
1870 
1871 
1897 _MHD_EXTERN int
1898 MHD_set_connection_value (struct MHD_Connection *connection,
1899  enum MHD_ValueKind kind,
1900  const char *key,
1901  const char *value);
1902 
1903 
1920 _MHD_EXTERN void
1921 MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
1922 
1923 
1933 _MHD_EXTERN size_t
1934 MHD_http_unescape (char *val);
1935 
1936 
1947 _MHD_EXTERN const char *
1948 MHD_lookup_connection_value (struct MHD_Connection *connection,
1949  enum MHD_ValueKind kind,
1950  const char *key);
1951 
1952 
1964 _MHD_EXTERN int
1965 MHD_queue_response (struct MHD_Connection *connection,
1966  unsigned int status_code,
1967  struct MHD_Response *response);
1968 
1969 
1997 _MHD_EXTERN void
1998 MHD_suspend_connection (struct MHD_Connection *connection);
1999 
2000 
2015 _MHD_EXTERN void
2016 MHD_resume_connection (struct MHD_Connection *connection);
2017 
2018 
2019 /* **************** Response manipulation functions ***************** */
2020 
2021 
2026 {
2031 
2038 
2039 };
2040 
2041 
2046 {
2051 };
2052 
2053 
2062 _MHD_EXTERN int
2063 MHD_set_response_options (struct MHD_Response *response,
2064  enum MHD_ResponseFlags flags,
2065  ...);
2066 
2067 
2084 _MHD_EXTERN struct MHD_Response *
2085 MHD_create_response_from_callback (uint64_t size,
2086  size_t block_size,
2089 
2090 
2105 _MHD_DEPR_FUNC("MHD_create_response_from_data() is deprecated, use MHD_create_response_from_buffer()") \
2106 _MHD_EXTERN struct MHD_Response *
2107 MHD_create_response_from_data (size_t size,
2108  void *data,
2109  int must_free,
2110  int must_copy);
2111 
2112 
2119 {
2120 
2128 
2136 
2145 
2146 };
2147 
2148 
2159 _MHD_EXTERN struct MHD_Response *
2160 MHD_create_response_from_buffer (size_t size,
2161  void *buffer,
2162  enum MHD_ResponseMemoryMode mode);
2163 
2164 
2176 _MHD_EXTERN struct MHD_Response *
2177 MHD_create_response_from_fd (size_t size,
2178  int fd);
2179 
2180 
2194 _MHD_EXTERN struct MHD_Response *
2195 MHD_create_response_from_fd64 (uint64_t size,
2196  int fd);
2197 
2198 
2215 _MHD_DEPR_FUNC("Function MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \
2216 _MHD_EXTERN struct MHD_Response *
2218  int fd,
2219  off_t offset);
2220 
2221 #if !defined(_MHD_NO_DEPR_IN_MACRO) || defined(_MHD_NO_DEPR_FUNC)
2222 /* Substitute MHD_create_response_from_fd_at_offset64() instead of MHD_create_response_from_fd_at_offset()
2223  to minimize potential problems with different off_t sizes */
2224 #define MHD_create_response_from_fd_at_offset(size,fd,offset) \
2225  _MHD_DEPR_IN_MACRO("Usage of MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \
2226  MHD_create_response_from_fd_at_offset64((size),(fd),(offset))
2227 #endif /* !_MHD_NO_DEPR_IN_MACRO || _MHD_NO_DEPR_FUNC */
2228 
2229 
2246 _MHD_EXTERN struct MHD_Response *
2248  int fd,
2249  uint64_t offset);
2250 
2251 
2259 {
2260 
2267 
2268 };
2269 
2270 
2277 
2278 
2291 _MHD_EXTERN int
2293  enum MHD_UpgradeAction action,
2294  ...);
2295 
2296 
2341 typedef void
2342 (*MHD_UpgradeHandler)(void *cls,
2343  struct MHD_Connection *connection,
2344  void *con_cls,
2345  const char *extra_in,
2346  size_t extra_in_size,
2347  MHD_socket sock,
2348  struct MHD_UpgradeResponseHandle *urh);
2349 
2350 
2380 _MHD_EXTERN struct MHD_Response *
2382  void *upgrade_handler_cls);
2383 
2384 
2394 _MHD_EXTERN void
2395 MHD_destroy_response (struct MHD_Response *response);
2396 
2397 
2408 _MHD_EXTERN int
2409 MHD_add_response_header (struct MHD_Response *response,
2410  const char *header,
2411  const char *content);
2412 
2413 
2423 _MHD_EXTERN int
2424 MHD_add_response_footer (struct MHD_Response *response,
2425  const char *footer,
2426  const char *content);
2427 
2428 
2438 _MHD_EXTERN int
2439 MHD_del_response_header (struct MHD_Response *response,
2440  const char *header,
2441  const char *content);
2442 
2443 
2454 _MHD_EXTERN int
2455 MHD_get_response_headers (struct MHD_Response *response,
2456  MHD_KeyValueIterator iterator, void *iterator_cls);
2457 
2458 
2467 _MHD_EXTERN const char *
2468 MHD_get_response_header (struct MHD_Response *response,
2469  const char *key);
2470 
2471 
2472 /* ********************** PostProcessor functions ********************** */
2473 
2499 _MHD_EXTERN struct MHD_PostProcessor *
2500 MHD_create_post_processor (struct MHD_Connection *connection,
2501  size_t buffer_size,
2502  MHD_PostDataIterator iter, void *iter_cls);
2503 
2504 
2518 _MHD_EXTERN int
2519 MHD_post_process (struct MHD_PostProcessor *pp,
2520  const char *post_data, size_t post_data_len);
2521 
2522 
2533 _MHD_EXTERN int
2534 MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
2535 
2536 
2537 /* ********************* Digest Authentication functions *************** */
2538 
2539 
2545 #define MHD_INVALID_NONCE -1
2546 
2547 
2556 _MHD_EXTERN char *
2557 MHD_digest_auth_get_username (struct MHD_Connection *connection);
2558 
2559 
2573 _MHD_EXTERN int
2574 MHD_digest_auth_check (struct MHD_Connection *connection,
2575  const char *realm,
2576  const char *username,
2577  const char *password,
2578  unsigned int nonce_timeout);
2579 
2580 
2595 _MHD_EXTERN int
2596 MHD_queue_auth_fail_response (struct MHD_Connection *connection,
2597  const char *realm,
2598  const char *opaque,
2599  struct MHD_Response *response,
2600  int signal_stale);
2601 
2602 
2612 _MHD_EXTERN char *
2614  char** password);
2615 
2616 
2629 _MHD_EXTERN int
2631  const char *realm,
2632  struct MHD_Response *response);
2633 
2634 /* ********************** generic query functions ********************** */
2635 
2636 
2647 _MHD_EXTERN const union MHD_ConnectionInfo *
2648 MHD_get_connection_info (struct MHD_Connection *connection,
2649  enum MHD_ConnectionInfoType info_type,
2650  ...);
2651 
2652 
2658 {
2659 
2666 
2667 };
2668 
2669 
2679 _MHD_EXTERN int
2680 MHD_set_connection_option (struct MHD_Connection *connection,
2682  ...);
2683 
2684 
2689 {
2694  size_t key_size;
2695 
2701 
2707 
2711  unsigned int num_connections;
2712 };
2713 
2714 
2726 _MHD_EXTERN const union MHD_DaemonInfo *
2727 MHD_get_daemon_info (struct MHD_Daemon *daemon,
2728  enum MHD_DaemonInfoType info_type,
2729  ...);
2730 
2731 
2738 _MHD_EXTERN const char*
2739 MHD_get_version (void);
2740 
2741 
2747 {
2753 
2762 
2768 
2774 
2782 
2788 
2795 
2802 
2808 
2815 
2822 
2830 
2838 
2845 
2855 
2860 };
2861 
2862 
2874 _MHD_EXTERN int
2875 MHD_is_feature_supported (enum MHD_FEATURE feature);
2876 
2877 
2878 #if 0 /* keep Emacsens' auto-indent happy */
2879 {
2880 #endif
2881 #ifdef __cplusplus
2882 }
2883 #endif
2884 
2885 #endif
#define _MHD_DEPR_FUNC(msg)
Definition: microhttpd.h:264
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
Definition: microhttpd.h:1482
_MHD_EXTERN struct MHD_Daemon * MHD_start_daemon_va(unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap)
Definition: daemon.c:4435
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_callback(uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc)
Definition: response.c:262
_MHD_EXTERN const char * MHD_get_version(void)
Definition: daemon.c:5514
size_t mac_key_size
Definition: microhttpd.h:2700
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
Definition: connection.c:446
MHD_socket listen_fd
Definition: microhttpd.h:2706
void * socket_context
Definition: internal.h:643
void * data
Definition: microhttpd.h:2108
_MHD_EXTERN int MHD_add_response_header(struct MHD_Response *response, const char *header, const char *content)
Definition: response.c:112
void int int must_copy
Definition: microhttpd.h:2108
MHD_ContentReaderFreeCallback crfc
Definition: internal.h:296
_MHD_EXTERN int MHD_get_timeout(struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
Definition: daemon.c:2615
void(* MHD_ContentReaderFreeCallback)(void *cls)
Definition: microhttpd.h:1549
char * version
Definition: internal.h:660
_MHD_EXTERN int MHD_add_connection(struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
Definition: daemon.c:2353
int(* MHD_PostDataIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size)
Definition: microhttpd.h:1572
_MHD_EXTERN int MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
Definition: basicauth.c:120
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd64(uint64_t size, int fd)
Definition: response.c:522
MHD_RequestTerminationCode
Definition: microhttpd.h:1099
_MHD_EXTERN int MHD_destroy_post_processor(struct MHD_PostProcessor *pp)
MHD_socket connect_fd
Definition: microhttpd.h:1199
_MHD_EXTERN int MHD_digest_auth_check(struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout)
Definition: digestauth.c:672
int MHD_socket
Definition: microhttpd.h:181
_MHD_EXTERN struct MHD_Daemon * MHD_start_daemon(unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...)
Definition: daemon.c:3777
intptr_t value
Definition: microhttpd.h:1038
MHD_ConnectionNotificationCode
Definition: microhttpd.h:1157
_MHD_EXTERN void MHD_set_panic_func(MHD_PanicCallback cb, void *cls)
Definition: daemon.c:5499
#define MHD_UNSIGNED_LONG_LONG
Definition: microhttpd.h:277
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
Definition: microhttpd.h:1353
_MHD_EXTERN struct MHD_PostProcessor * MHD_create_post_processor(struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls)
void(* MHD_LogCallback)(void *cls, const char *fm, va_list ap)
Definition: microhttpd.h:710
MHD_ResponseOptions
Definition: microhttpd.h:2045
_MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
Definition: connection.c:3204
MHD_CONNECTION_OPTION
Definition: microhttpd.h:2657
_MHD_EXTERN char * MHD_basic_auth_get_username_password(struct MHD_Connection *connection, char **password)
Definition: basicauth.c:47
int fd
Definition: microhttpd.h:2218
_MHD_EXTERN void MHD_stop_daemon(struct MHD_Daemon *daemon)
Definition: daemon.c:5269
const char * url
Definition: internal.h:654
MHD_UpgradeHandler upgrade_handler
Definition: internal.h:303
_MHD_EXTERN int MHD_queue_auth_fail_response(struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale)
Definition: digestauth.c:946
_MHD_EXTERN int MHD_add_response_footer(struct MHD_Response *response, const char *footer, const char *content)
Definition: response.c:133
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset64(uint64_t size, int fd, uint64_t offset)
Definition: response.c:457
char * method
Definition: internal.h:648
#define _MHD_EXTERN
Definition: microhttpd.h:171
_MHD_EXTERN int MHD_run_from_select(struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set)
Definition: daemon.c:2712
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
Definition: microhttpd.h:1533
_MHD_EXTERN char * MHD_digest_auth_get_username(struct MHD_Connection *connection)
Definition: digestauth.c:467
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
Definition: response.c:994
_MHD_EXTERN void MHD_suspend_connection(struct MHD_Connection *connection)
Definition: daemon.c:2158
_MHD_EXTERN int MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
Definition: connection.c:3252
void int must_free
Definition: microhttpd.h:2108
uint16_t port
Definition: internal.h:1408
struct MHD_Response * MHD_create_response_from_data(size_t size, void *data, int must_free, int must_copy)
Definition: response.c:546
MHD_ValueKind
Definition: microhttpd.h:1053
struct MHD_Daemon * daemon
Definition: microhttpd.h:1220
_MHD_EXTERN int MHD_post_process(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
#define MHD_create_response_from_fd_at_offset(size, fd, offset)
Definition: microhttpd.h:2224
MHD_FEATURE
Definition: microhttpd.h:2746
MHD_ConnectionInfoType
Definition: microhttpd.h:1235
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd(size_t size, int fd)
Definition: response.c:499
_MHD_EXTERN int MHD_upgrade_action(struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeAction action,...)
Definition: response.c:625
int off_t offset
Definition: microhttpd.h:2218
_MHD_EXTERN int MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
Definition: connection.c:3310
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
Definition: response.c:601
MHD_AcceptPolicyCallback apc
Definition: internal.h:1196
int(* MHD_AccessHandlerCallback)(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls)
Definition: microhttpd.h:1412
_MHD_EXTERN struct MHD_Response * MHD_create_response_for_upgrade(MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls)
Definition: response.c:952
void * ptr_value
Definition: microhttpd.h:1044
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
Definition: microhttpd.h:1435
void(* MHD_UpgradeHandler)(void *cls, struct MHD_Connection *connection, void *con_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh)
Definition: microhttpd.h:2342
_MHD_EXTERN int MHD_set_response_options(struct MHD_Response *response, enum MHD_ResponseFlags flags,...)
Definition: response.c:303
_MHD_EXTERN int MHD_get_connection_values(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
Definition: connection.c:352
_MHD_EXTERN int MHD_run(struct MHD_Daemon *daemon)
Definition: daemon.c:3640
MHD_OPTION
MHD options.
Definition: microhttpd.h:720
void * apc_cls
Definition: internal.h:1201
#define MHD_get_fdset(daemon, read_fd_set, write_fd_set, except_fd_set, max_fd)
Definition: microhttpd.h:1778
MHD_ContentReaderCallback crc
Definition: internal.h:290
void * crc_cls
Definition: internal.h:284
MHD_UpgradeAction
Definition: microhttpd.h:2258
MHD_DaemonInfoType
Definition: microhttpd.h:1309
_MHD_EXTERN int MHD_is_feature_supported(enum MHD_FEATURE feature)
Definition: daemon.c:5548
struct sockaddr * client_addr
Definition: microhttpd.h:1214
_MHD_EXTERN int MHD_del_response_header(struct MHD_Response *response, const char *header, const char *content)
Definition: response.c:154
#define _MHD_DEPR_MACRO(msg)
Definition: microhttpd.h:235
_MHD_EXTERN int MHD_get_fdset2(struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize)
Definition: daemon.c:753
MHD_ResponseFlags
Definition: microhttpd.h:2025
_MHD_EXTERN const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
Definition: response.c:230
_MHD_EXTERN MHD_socket MHD_quiesce_daemon(struct MHD_Daemon *daemon)
Definition: daemon.c:3822
unsigned int num_connections
Definition: microhttpd.h:2711
int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Definition: microhttpd.h:1367
void(* MHD_NotifyConnectionCallback)(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
Definition: microhttpd.h:1460
_MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info(struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type,...)
Definition: daemon.c:5445
_MHD_EXTERN size_t MHD_http_unescape(char *val)
Definition: internal.c:138
void * upgrade_handler_cls
Definition: internal.h:308
_MHD_EXTERN const char * MHD_get_reason_phrase_for(unsigned int code)
enum MHD_OPTION option
Definition: microhttpd.h:1031
_MHD_EXTERN int MHD_set_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value)
Definition: connection.c:404
MHD_FLAG
Flags for the struct MHD_Daemon.
Definition: microhttpd.h:527
_MHD_EXTERN int MHD_get_response_headers(struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)
Definition: response.c:200
MHD_ResponseMemoryMode
Definition: microhttpd.h:2118
_MHD_EXTERN void MHD_resume_connection(struct MHD_Connection *connection)
Definition: daemon.c:2223