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-2015 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 
86 #ifndef MHD_MICROHTTPD_H
87 #define MHD_MICROHTTPD_H
88 
89 #ifdef __cplusplus
90 extern "C"
91 {
92 #if 0 /* keep Emacsens' auto-indent happy */
93 }
94 #endif
95 #endif
96 
97 /* While we generally would like users to use a configure-driven
98  build process which detects which headers are present and
99  hence works on any platform, we use "standard" includes here
100  to build out-of-the-box for beginning users on common systems.
101 
102  Once you have a proper build system and go for more exotic
103  platforms, you should define MHD_PLATFORM_H in some header that
104  you always include *before* "microhttpd.h". Then the following
105  "standard" includes won't be used (which might be a good
106  idea, especially on platforms where they do not exist). */
107 #ifndef MHD_PLATFORM_H
108 #include <stdarg.h>
109 #include <stdint.h>
110 #include <sys/types.h>
111 #if defined(_WIN32) && !defined(__CYGWIN__)
112 #include <ws2tcpip.h>
113 #if defined(_MSC_FULL_VER) && !defined (_SSIZE_T_DEFINED)
114 #define _SSIZE_T_DEFINED
115 typedef intptr_t ssize_t;
116 #endif /* !_SSIZE_T_DEFINED */
117 #else
118 #include <unistd.h>
119 #include <sys/time.h>
120 #include <sys/socket.h>
121 #endif
122 #endif
123 
124 #if defined(__CYGWIN__) && !defined(_SYS_TYPES_FD_SET)
125 /* Do not define __USE_W32_SOCKETS under Cygwin! */
126 #error Cygwin with winsock fd_set is not supported
127 #endif
128 
133 #define MHD_VERSION 0x00094601
134 
138 #define MHD_YES 1
139 
143 #define MHD_NO 0
144 
148 #define MHD_INVALID_NONCE -1
149 
154 #ifdef UINT64_MAX
155 #define MHD_SIZE_UNKNOWN UINT64_MAX
156 #else
157 #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
158 #endif
159 
160 #ifdef SIZE_MAX
161 #define MHD_CONTENT_READER_END_OF_STREAM SIZE_MAX
162 #define MHD_CONTENT_READER_END_WITH_ERROR (SIZE_MAX - 1)
163 #else
164 #define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL)
165 #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1)
166 #endif
167 
168 #ifndef _MHD_EXTERN
169 #if defined(_WIN32) && defined(MHD_W32LIB)
170 #define _MHD_EXTERN extern
171 #elif defined (_WIN32) && defined(MHD_W32DLL)
172 /* Define MHD_W32DLL when using MHD as W32 .DLL to speed up linker a little */
173 #define _MHD_EXTERN __declspec(dllimport)
174 #else
175 #define _MHD_EXTERN extern
176 #endif
177 #endif
178 
179 #ifndef MHD_SOCKET_DEFINED
180 
183 #if !defined(_WIN32) || defined(_SYS_TYPES_FD_SET)
184 #define MHD_POSIX_SOCKETS 1
185 typedef int MHD_socket;
186 #define MHD_INVALID_SOCKET (-1)
187 #else /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
188 #define MHD_WINSOCK_SOCKETS 1
189 #include <winsock2.h>
190 typedef SOCKET MHD_socket;
191 #define MHD_INVALID_SOCKET (INVALID_SOCKET)
192 #endif /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */
193 #define MHD_SOCKET_DEFINED 1
194 #endif /* MHD_SOCKET_DEFINED */
195 
199 #ifdef MHD_NO_DEPRECATION
200 #define _MHD_DEPR_MACRO(msg)
201 #define _MHD_DEPR_FUNC(msg)
202 #endif /* MHD_NO_DEPRECATION */
203 
204 #ifndef _MHD_DEPR_MACRO
205 #if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1500
206 /* Stringify macros */
207 #define _MHD_INSTRMACRO(a) #a
208 #define _MHD_STRMACRO(a) _MHD_INSTRMACRO(a)
209 #define _MHD_DEPR_MACRO(msg) __pragma(message(__FILE__ "(" _MHD_STRMACRO(__LINE__)"): warning: " msg))
210 #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg)
211 #elif defined(__clang__) || defined (__GNUC_PATCHLEVEL__)
212 #define _MHD_GCC_PRAG(x) _Pragma (#x)
213 #if __clang_major__+0 >= 5 || \
214  (!defined(__apple_build_version__) && (__clang_major__+0 > 3 || (__clang_major__+0 == 3 && __clang_minor__ >= 3))) || \
215  __GNUC__+0 > 4 || (__GNUC__+0 == 4 && __GNUC_MINOR__+0 >= 8)
216 #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(GCC warning msg)
217 #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg)
218 #else /* older clang or GCC */
219 #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(message msg)
220 #if (__clang_major__+0 > 2 || (__clang_major__+0 == 2 && __clang_minor__ >= 9)) /* FIXME: earlier versions not tested */
221 /* clang handles inline pragmas better than GCC */
222 #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg)
223 #endif /* clang >= 2.9 */
224 #endif
225 /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */
226 #else /* other compilers */
227 #define _MHD_DEPR_MACRO(msg)
228 #endif
229 #endif /* _MHD_DEPR_MACRO */
230 
231 #ifndef _MHD_DEPR_IN_MACRO
232 #define _MHD_NO_DEPR_IN_MACRO 1
233 #define _MHD_DEPR_IN_MACRO(msg)
234 #endif /* !_MHD_DEPR_IN_MACRO */
235 
236 #ifndef _MHD_DEPR_FUNC
237 #if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1400
238 #define _MHD_DEPR_FUNC(msg) __declspec(deprecated(msg))
239 #elif defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1310
240 /* VS .NET 2003 deprecation do not support custom messages */
241 #define _MHD_DEPR_FUNC(msg) __declspec(deprecated)
242 #elif (__GNUC__+0 >= 5) || (defined (__clang__) && \
243  (__clang_major__+0 > 2 || (__clang_major__+0 == 2 && __clang_minor__ >= 9))) /* FIXME: earlier versions not tested */
244 #define _MHD_DEPR_FUNC(msg) __attribute__((deprecated(msg)))
245 #elif defined (__clang__) || __GNUC__+0 > 3 || (__GNUC__+0 == 3 && __GNUC_MINOR__+0 >= 1)
246 /* old GCC-style deprecation do not support custom messages */
247 #define _MHD_DEPR_FUNC(msg) __attribute__((__deprecated__))
248 /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */
249 #else /* other compilers */
250 #define _MHD_DEPR_FUNC(msg)
251 #endif
252 #endif /* _MHD_DEPR_FUNC */
253 
259 #ifndef MHD_LONG_LONG
260 
263 #define MHD_LONG_LONG long long
264 #define MHD_UNSIGNED_LONG_LONG unsigned long long
265 #else /* MHD_LONG_LONG */
266 _MHD_DEPR_MACRO("Macro MHD_LONG_LONG is deprecated, use MHD_UNSIGNED_LONG_LONG")
267 #endif
268 
272 #ifndef MHD_LONG_LONG_PRINTF
273 
276 #define MHD_LONG_LONG_PRINTF "ll"
277 #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu"
278 #else /* MHD_LONG_LONG_PRINTF */
279 _MHD_DEPR_MACRO("Macro MHD_LONG_LONG_PRINTF is deprecated, use MHD_UNSIGNED_LONG_LONG_PRINTF")
280 #endif
281 
282 
288 #define MHD_HTTP_CONTINUE 100
289 #define MHD_HTTP_SWITCHING_PROTOCOLS 101
290 #define MHD_HTTP_PROCESSING 102
291 
292 #define MHD_HTTP_OK 200
293 #define MHD_HTTP_CREATED 201
294 #define MHD_HTTP_ACCEPTED 202
295 #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
296 #define MHD_HTTP_NO_CONTENT 204
297 #define MHD_HTTP_RESET_CONTENT 205
298 #define MHD_HTTP_PARTIAL_CONTENT 206
299 #define MHD_HTTP_MULTI_STATUS 207
300 
301 #define MHD_HTTP_MULTIPLE_CHOICES 300
302 #define MHD_HTTP_MOVED_PERMANENTLY 301
303 #define MHD_HTTP_FOUND 302
304 #define MHD_HTTP_SEE_OTHER 303
305 #define MHD_HTTP_NOT_MODIFIED 304
306 #define MHD_HTTP_USE_PROXY 305
307 #define MHD_HTTP_SWITCH_PROXY 306
308 #define MHD_HTTP_TEMPORARY_REDIRECT 307
309 
310 #define MHD_HTTP_BAD_REQUEST 400
311 #define MHD_HTTP_UNAUTHORIZED 401
312 #define MHD_HTTP_PAYMENT_REQUIRED 402
313 #define MHD_HTTP_FORBIDDEN 403
314 #define MHD_HTTP_NOT_FOUND 404
315 #define MHD_HTTP_METHOD_NOT_ALLOWED 405
316 #define MHD_HTTP_NOT_ACCEPTABLE 406
317 
318 #define MHD_HTTP_METHOD_NOT_ACCEPTABLE \
319  _MHD_DEPR_IN_MACRO("Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE") 406
320 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
321 #define MHD_HTTP_REQUEST_TIMEOUT 408
322 #define MHD_HTTP_CONFLICT 409
323 #define MHD_HTTP_GONE 410
324 #define MHD_HTTP_LENGTH_REQUIRED 411
325 #define MHD_HTTP_PRECONDITION_FAILED 412
326 #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
327 #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
328 #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
329 #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
330 #define MHD_HTTP_EXPECTATION_FAILED 417
331 #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
332 #define MHD_HTTP_LOCKED 423
333 #define MHD_HTTP_FAILED_DEPENDENCY 424
334 #define MHD_HTTP_UNORDERED_COLLECTION 425
335 #define MHD_HTTP_UPGRADE_REQUIRED 426
336 #define MHD_HTTP_NO_RESPONSE 444
337 #define MHD_HTTP_RETRY_WITH 449
338 #define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS 450
339 #define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451
340 
341 #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
342 #define MHD_HTTP_NOT_IMPLEMENTED 501
343 #define MHD_HTTP_BAD_GATEWAY 502
344 #define MHD_HTTP_SERVICE_UNAVAILABLE 503
345 #define MHD_HTTP_GATEWAY_TIMEOUT 504
346 #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
347 #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
348 #define MHD_HTTP_INSUFFICIENT_STORAGE 507
349 #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
350 #define MHD_HTTP_NOT_EXTENDED 510
351  /* end of group httpcode */
353 
360 const char *
361 MHD_get_reason_phrase_for (unsigned int code);
362 
363 
370 #define MHD_ICY_FLAG ((uint32_t)(((uint32_t)1) << 31))
371 
377 /* See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html */
378 #define MHD_HTTP_HEADER_ACCEPT "Accept"
379 #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
380 #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
381 #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
382 #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
383 #define MHD_HTTP_HEADER_AGE "Age"
384 #define MHD_HTTP_HEADER_ALLOW "Allow"
385 #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
386 #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
387 #define MHD_HTTP_HEADER_CONNECTION "Connection"
388 #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
389 #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
390 #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
391 #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
392 #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
393 #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
394 #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
395 #define MHD_HTTP_HEADER_COOKIE "Cookie"
396 #define MHD_HTTP_HEADER_DATE "Date"
397 #define MHD_HTTP_HEADER_ETAG "ETag"
398 #define MHD_HTTP_HEADER_EXPECT "Expect"
399 #define MHD_HTTP_HEADER_EXPIRES "Expires"
400 #define MHD_HTTP_HEADER_FROM "From"
401 #define MHD_HTTP_HEADER_HOST "Host"
402 #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
403 #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
404 #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
405 #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
406 #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
407 #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
408 #define MHD_HTTP_HEADER_LOCATION "Location"
409 #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
410 #define MHD_HTTP_HEADER_PRAGMA "Pragma"
411 #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
412 #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
413 #define MHD_HTTP_HEADER_RANGE "Range"
414 /* This is not a typo, see HTTP spec */
415 #define MHD_HTTP_HEADER_REFERER "Referer"
416 #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
417 #define MHD_HTTP_HEADER_SERVER "Server"
418 #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie"
419 #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2"
420 #define MHD_HTTP_HEADER_TE "TE"
421 #define MHD_HTTP_HEADER_TRAILER "Trailer"
422 #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
423 #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
424 #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
425 #define MHD_HTTP_HEADER_VARY "Vary"
426 #define MHD_HTTP_HEADER_VIA "Via"
427 #define MHD_HTTP_HEADER_WARNING "Warning"
428 #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
429 #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN "Access-Control-Allow-Origin"
430 #define MHD_HTTP_HEADER_CONTENT_DISPOSITION "Content-Disposition"
431  /* end of group headers */
433 
440 #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
441 #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
442  /* end of group versions */
444 
450 #define MHD_HTTP_METHOD_CONNECT "CONNECT"
451 #define MHD_HTTP_METHOD_DELETE "DELETE"
452 #define MHD_HTTP_METHOD_GET "GET"
453 #define MHD_HTTP_METHOD_HEAD "HEAD"
454 #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
455 #define MHD_HTTP_METHOD_POST "POST"
456 #define MHD_HTTP_METHOD_PUT "PUT"
457 #define MHD_HTTP_METHOD_PATCH "PATCH"
458 #define MHD_HTTP_METHOD_TRACE "TRACE"
459  /* end of group methods */
461 
467 #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
468 #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
469  /* end of group postenc */
471 
472 
477 struct MHD_Daemon;
478 
487 struct MHD_Connection;
488 
493 struct MHD_Response;
494 
499 struct MHD_PostProcessor;
500 
501 
514 {
519 
525 
530 
535 
540 
549 
560 
569 
574 
582 
591 
599 
606 
624 
629 
638 
644 
651 
652 };
653 
654 
663 typedef void (*MHD_LogCallback)(void *cls, const char *fm, va_list ap);
664 
665 
672 {
673 
679 
688 
694 
701 
715 
727 
735 
763 
771 
779 
786 
792 
800 
813 
823 
844 
864 
875 
882 
888 
895 
901 
917 
926 
933 
942 
951 
962 
963 };
964 
965 
970 {
976 
982  intptr_t value;
983 
988  void *ptr_value;
989 
990 };
991 
992 
998 {
999 
1004 
1009 
1015 
1025 
1030 
1035 };
1036 
1037 
1044 {
1045 
1051 
1059 
1067 
1074 
1084 
1092 
1093 };
1094 
1095 
1102 {
1103 
1109 
1115 
1116 };
1117 
1118 
1123 {
1124 
1128  int /* enum gnutls_cipher_algorithm */ cipher_algorithm;
1129 
1133  int /* enum gnutls_protocol */ protocol;
1134 
1139 
1143  void * /* gnutls_session_t */ tls_session;
1144 
1148  void * /* gnutls_x509_crt_t */ client_cert;
1149 
1153  struct sockaddr *client_addr;
1154 
1160 
1166 };
1167 
1168 
1175 {
1182 
1189 
1198 
1204 
1212 
1218 
1225 
1235 
1236 };
1237 
1238 
1244 {
1249 
1254 
1260 
1266 
1272 };
1273 
1274 
1285 typedef void
1286 (*MHD_PanicCallback) (void *cls,
1287  const char *file,
1288  unsigned int line,
1289  const char *reason);
1290 
1299 typedef int
1301  const struct sockaddr *addr,
1302  socklen_t addrlen);
1303 
1304 
1344 typedef int
1346  struct MHD_Connection *connection,
1347  const char *url,
1348  const char *method,
1349  const char *version,
1350  const char *upload_data,
1351  size_t *upload_data_size,
1352  void **con_cls);
1353 
1354 
1367 typedef void
1369  struct MHD_Connection *connection,
1370  void **con_cls,
1371  enum MHD_RequestTerminationCode toe);
1372 
1392 typedef void
1394  struct MHD_Connection *connection,
1395  void **socket_context,
1397 
1398 
1414 typedef int
1415 (*MHD_KeyValueIterator) (void *cls,
1416  enum MHD_ValueKind kind,
1417  const char *key,
1418  const char *value);
1419 
1420 
1465 typedef ssize_t
1467  uint64_t pos,
1468  char *buf,
1469  size_t max);
1470 
1471 
1481 typedef void
1483 
1484 
1504 typedef int
1505 (*MHD_PostDataIterator) (void *cls,
1506  enum MHD_ValueKind kind,
1507  const char *key,
1508  const char *filename,
1509  const char *content_type,
1510  const char *transfer_encoding,
1511  const char *data,
1512  uint64_t off,
1513  size_t size);
1514 
1515 /* **************** Daemon handling functions ***************** */
1516 
1534 _MHD_EXTERN struct MHD_Daemon *
1535 MHD_start_daemon_va (unsigned int flags,
1536  uint16_t port,
1538  MHD_AccessHandlerCallback dh, void *dh_cls,
1539  va_list ap);
1540 
1541 
1558 _MHD_EXTERN struct MHD_Daemon *
1559 MHD_start_daemon (unsigned int flags,
1560  uint16_t port,
1562  MHD_AccessHandlerCallback dh, void *dh_cls,
1563  ...);
1564 
1565 
1586 MHD_quiesce_daemon (struct MHD_Daemon *daemon);
1587 
1588 
1595 _MHD_EXTERN void
1596 MHD_stop_daemon (struct MHD_Daemon *daemon);
1597 
1598 
1628 _MHD_EXTERN int
1629 MHD_add_connection (struct MHD_Daemon *daemon,
1630  MHD_socket client_socket,
1631  const struct sockaddr *addr,
1632  socklen_t addrlen);
1633 
1634 
1654 _MHD_EXTERN int
1655 MHD_get_fdset (struct MHD_Daemon *daemon,
1656  fd_set *read_fd_set,
1657  fd_set *write_fd_set,
1658  fd_set *except_fd_set,
1659  MHD_socket *max_fd);
1660 
1661 
1683 _MHD_EXTERN int
1684 MHD_get_fdset2 (struct MHD_Daemon *daemon,
1685  fd_set *read_fd_set,
1686  fd_set *write_fd_set,
1687  fd_set *except_fd_set,
1688  MHD_socket *max_fd,
1689  unsigned int fd_setsize);
1690 
1691 
1711 #define MHD_get_fdset(daemon,read_fd_set,write_fd_set,except_fd_set,max_fd) \
1712  MHD_get_fdset2((daemon),(read_fd_set),(write_fd_set),(except_fd_set),(max_fd),FD_SETSIZE)
1713 
1714 
1729 _MHD_EXTERN int
1730 MHD_get_timeout (struct MHD_Daemon *daemon,
1731  MHD_UNSIGNED_LONG_LONG *timeout);
1732 
1733 
1753 _MHD_EXTERN int
1754 MHD_run (struct MHD_Daemon *daemon);
1755 
1756 
1776 _MHD_EXTERN int
1777 MHD_run_from_select (struct MHD_Daemon *daemon,
1778  const fd_set *read_fd_set,
1779  const fd_set *write_fd_set,
1780  const fd_set *except_fd_set);
1781 
1782 
1783 
1784 
1785 /* **************** Connection handling functions ***************** */
1786 
1798 _MHD_EXTERN int
1799 MHD_get_connection_values (struct MHD_Connection *connection,
1800  enum MHD_ValueKind kind,
1801  MHD_KeyValueIterator iterator,
1802  void *iterator_cls);
1803 
1804 
1830 _MHD_EXTERN int
1831 MHD_set_connection_value (struct MHD_Connection *connection,
1832  enum MHD_ValueKind kind,
1833  const char *key,
1834  const char *value);
1835 
1836 
1853 _MHD_EXTERN void
1854 MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
1855 
1856 
1866 _MHD_EXTERN size_t
1867 MHD_http_unescape (char *val);
1868 
1869 
1880 _MHD_EXTERN const char *
1881 MHD_lookup_connection_value (struct MHD_Connection *connection,
1882  enum MHD_ValueKind kind,
1883  const char *key);
1884 
1885 
1897 _MHD_EXTERN int
1898 MHD_queue_response (struct MHD_Connection *connection,
1899  unsigned int status_code,
1900  struct MHD_Response *response);
1901 
1902 
1930 _MHD_EXTERN void
1931 MHD_suspend_connection (struct MHD_Connection *connection);
1932 
1933 
1942 _MHD_EXTERN void
1943 MHD_resume_connection (struct MHD_Connection *connection);
1944 
1945 
1946 /* **************** Response manipulation functions ***************** */
1947 
1948 
1953 {
1958 
1965 
1966 };
1967 
1968 
1973 {
1978 };
1979 
1980 
1989 _MHD_EXTERN int
1990 MHD_set_response_options (struct MHD_Response *response,
1991  enum MHD_ResponseFlags flags,
1992  ...);
1993 
1994 
2011 _MHD_EXTERN struct MHD_Response *
2012 MHD_create_response_from_callback (uint64_t size,
2013  size_t block_size,
2016 
2017 
2032 _MHD_DEPR_FUNC("MHD_create_response_from_data() is deprecated, use MHD_create_response_from_buffer()") \
2033 _MHD_EXTERN struct MHD_Response *
2034 MHD_create_response_from_data (size_t size,
2035  void *data,
2036  int must_free,
2037  int must_copy);
2038 
2039 
2046 {
2047 
2055 
2063 
2072 
2073 };
2074 
2075 
2086 _MHD_EXTERN struct MHD_Response *
2087 MHD_create_response_from_buffer (size_t size,
2088  void *buffer,
2089  enum MHD_ResponseMemoryMode mode);
2090 
2091 
2103 _MHD_EXTERN struct MHD_Response *
2104 MHD_create_response_from_fd (size_t size,
2105  int fd);
2106 
2107 
2121 _MHD_EXTERN struct MHD_Response *
2122 MHD_create_response_from_fd64 (uint64_t size,
2123  int fd);
2124 
2125 
2142 _MHD_DEPR_FUNC("Function MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \
2143 _MHD_EXTERN struct MHD_Response *
2145  int fd,
2146  off_t offset);
2147 
2148 #ifndef _MHD_NO_DEPR_IN_MACRO
2149 /* Substitute MHD_create_response_from_fd_at_offset64() instead of MHD_create_response_from_fd_at_offset()
2150  to minimize possible problems with different off_t options */
2151 #define MHD_create_response_from_fd_at_offset(size,fd,offset) \
2152  _MHD_DEPR_IN_MACRO("Usage of MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \
2153  MHD_create_response_from_fd_at_offset64((size),(fd),(offset))
2154 #endif /* ! _MHD_NO_DEPR_IN_MACRO */
2155 
2156 
2173 _MHD_EXTERN struct MHD_Response *
2175  int fd,
2176  uint64_t offset);
2177 
2178 
2179 #if 0
2180 
2186 enum MHD_UpgradeAction
2187 {
2188 
2197  MHD_UPGRADE_ACTION_CLOSE = 0,
2198 
2208  MHD_UPGRADE_ACTION_CORK
2209 
2210 };
2211 
2212 
2224 typedef int
2225 (*MHD_UpgradeActionCallback)(void *cls,
2226  enum MHD_UpgradeAction action,
2227  ...);
2228 
2274 typedef void
2275 (*MHD_UpgradeHandler)(void *cls,
2276  struct MHD_Connection *connection,
2277  MHD_SOCKET sock,
2278  MHD_UpgradeActionCallback upgrade_action,
2279  void *upgrade_action_cls);
2280 
2281 
2311 struct MHD_Response *
2312 MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler,
2313  void *upgrade_handler_cls);
2314 #endif
2315 
2325 _MHD_EXTERN void
2326 MHD_destroy_response (struct MHD_Response *response);
2327 
2328 
2339 _MHD_EXTERN int
2340 MHD_add_response_header (struct MHD_Response *response,
2341  const char *header,
2342  const char *content);
2343 
2344 
2354 _MHD_EXTERN int
2355 MHD_add_response_footer (struct MHD_Response *response,
2356  const char *footer,
2357  const char *content);
2358 
2359 
2369 _MHD_EXTERN int
2370 MHD_del_response_header (struct MHD_Response *response,
2371  const char *header,
2372  const char *content);
2373 
2374 
2385 _MHD_EXTERN int
2386 MHD_get_response_headers (struct MHD_Response *response,
2387  MHD_KeyValueIterator iterator, void *iterator_cls);
2388 
2389 
2398 _MHD_EXTERN const char *
2399 MHD_get_response_header (struct MHD_Response *response,
2400  const char *key);
2401 
2402 
2403 /* ********************** PostProcessor functions ********************** */
2404 
2430 _MHD_EXTERN struct MHD_PostProcessor *
2431 MHD_create_post_processor (struct MHD_Connection *connection,
2432  size_t buffer_size,
2433  MHD_PostDataIterator iter, void *iter_cls);
2434 
2435 
2449 _MHD_EXTERN int
2450 MHD_post_process (struct MHD_PostProcessor *pp,
2451  const char *post_data, size_t post_data_len);
2452 
2453 
2464 _MHD_EXTERN int
2465 MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
2466 
2467 
2468 /* ********************* Digest Authentication functions *************** */
2469 
2470 
2476 #define MHD_INVALID_NONCE -1
2477 
2478 
2487 _MHD_EXTERN char *
2488 MHD_digest_auth_get_username (struct MHD_Connection *connection);
2489 
2490 
2504 _MHD_EXTERN int
2505 MHD_digest_auth_check (struct MHD_Connection *connection,
2506  const char *realm,
2507  const char *username,
2508  const char *password,
2509  unsigned int nonce_timeout);
2510 
2511 
2526 _MHD_EXTERN int
2527 MHD_queue_auth_fail_response (struct MHD_Connection *connection,
2528  const char *realm,
2529  const char *opaque,
2530  struct MHD_Response *response,
2531  int signal_stale);
2532 
2533 
2543 _MHD_EXTERN char *
2545  char** password);
2546 
2547 
2560 _MHD_EXTERN int
2562  const char *realm,
2563  struct MHD_Response *response);
2564 
2565 /* ********************** generic query functions ********************** */
2566 
2567 
2578 _MHD_EXTERN const union MHD_ConnectionInfo *
2579 MHD_get_connection_info (struct MHD_Connection *connection,
2580  enum MHD_ConnectionInfoType info_type,
2581  ...);
2582 
2583 
2589 {
2590 
2597 
2598 };
2599 
2600 
2610 _MHD_EXTERN int
2611 MHD_set_connection_option (struct MHD_Connection *connection,
2613  ...);
2614 
2615 
2620 {
2625  size_t key_size;
2626 
2632 
2638 
2642  unsigned int num_connections;
2643 };
2644 
2645 
2657 _MHD_EXTERN const union MHD_DaemonInfo *
2658 MHD_get_daemon_info (struct MHD_Daemon *daemon,
2659  enum MHD_DaemonInfoType info_type,
2660  ...);
2661 
2662 
2669 _MHD_EXTERN const char*
2670 MHD_get_version (void);
2671 
2672 
2678 {
2684 
2693 
2699 
2705 
2713 
2719 
2726 
2733 
2739 
2746 
2753 
2761 
2769 
2776 
2786 };
2787 
2788 
2800 _MHD_EXTERN int
2802 
2803 
2804 #if 0 /* keep Emacsens' auto-indent happy */
2805 {
2806 #endif
2807 #ifdef __cplusplus
2808 }
2809 #endif
2810 
2811 #endif
#define _MHD_DEPR_FUNC(msg)
Definition: microhttpd.h:250
void ** socket_context
Definition: microhttpd.h:1165
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
Definition: microhttpd.h:1415
_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:3615
_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:244
_MHD_EXTERN const char * MHD_get_version(void)
Definition: daemon.c:4711
size_t mac_key_size
Definition: microhttpd.h:2631
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
Definition: connection.c:219
MHD_socket listen_fd
Definition: microhttpd.h:2637
void * socket_context
Definition: internal.h:602
void * data
Definition: microhttpd.h:2035
_MHD_EXTERN int MHD_add_response_header(struct MHD_Response *response, const char *header, const char *content)
Definition: response.c:103
void int int must_copy
Definition: microhttpd.h:2035
MHD_ContentReaderFreeCallback crfc
Definition: internal.h:278
_MHD_EXTERN int MHD_get_timeout(struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
Definition: daemon.c:2120
void(* MHD_ContentReaderFreeCallback)(void *cls)
Definition: microhttpd.h:1482
char * version
Definition: internal.h:620
_MHD_EXTERN int MHD_add_connection(struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
Definition: daemon.c:1920
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:1505
_MHD_EXTERN int MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
Definition: basicauth.c:116
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd64(uint64_t size, int fd)
Definition: response.c:480
MHD_RequestTerminationCode
Definition: microhttpd.h:1043
_MHD_EXTERN int MHD_destroy_post_processor(struct MHD_PostProcessor *pp)
MHD_socket connect_fd
Definition: microhttpd.h:1138
_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:543
int MHD_socket
Definition: microhttpd.h:185
_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:2998
intptr_t value
Definition: microhttpd.h:982
MHD_ConnectionNotificationCode
Definition: microhttpd.h:1101
_MHD_EXTERN void MHD_set_panic_func(MHD_PanicCallback cb, void *cls)
Definition: daemon.c:4696
#define MHD_UNSIGNED_LONG_LONG
Definition: microhttpd.h:264
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
Definition: microhttpd.h:1286
_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:663
MHD_ResponseOptions
Definition: microhttpd.h:1972
_MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
Definition: connection.c:2730
MHD_CONNECTION_OPTION
Definition: microhttpd.h:2588
_MHD_EXTERN char * MHD_basic_auth_get_username_password(struct MHD_Connection *connection, char **password)
Definition: basicauth.c:46
int fd
Definition: microhttpd.h:2145
_MHD_EXTERN void MHD_stop_daemon(struct MHD_Daemon *daemon)
Definition: daemon.c:4485
_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:783
_MHD_EXTERN int MHD_add_response_footer(struct MHD_Response *response, const char *footer, const char *content)
Definition: response.c:123
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset64(uint64_t size, int fd, uint64_t offset)
Definition: response.c:421
char * method
Definition: internal.h:608
#define _MHD_EXTERN
Definition: microhttpd.h:175
_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:2217
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
Definition: microhttpd.h:1466
_MHD_EXTERN char * MHD_digest_auth_get_username(struct MHD_Connection *connection)
Definition: digestauth.c:368
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
Definition: response.c:574
_MHD_EXTERN void MHD_suspend_connection(struct MHD_Connection *connection)
Definition: daemon.c:1680
_MHD_EXTERN int MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
Definition: connection.c:2775
void int must_free
Definition: microhttpd.h:2035
uint16_t port
Definition: internal.h:1197
struct MHD_Response * MHD_create_response_from_data(size_t size, void *data, int must_free, int must_copy)
Definition: response.c:502
MHD_ValueKind
Definition: microhttpd.h:997
char * url
Definition: internal.h:614
struct MHD_Daemon * daemon
Definition: microhttpd.h:1159
_MHD_EXTERN int MHD_post_process(struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len)
MHD_FEATURE
Definition: microhttpd.h:2677
MHD_ConnectionInfoType
Definition: microhttpd.h:1174
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd(size_t size, int fd)
Definition: response.c:459
int off_t offset
Definition: microhttpd.h:2145
_MHD_EXTERN int MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
Definition: connection.c:2836
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
Definition: response.c:553
const char * MHD_get_reason_phrase_for(unsigned int code)
MHD_AcceptPolicyCallback apc
Definition: internal.h:1005
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:1345
void * ptr_value
Definition: microhttpd.h:988
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
Definition: microhttpd.h:1368
_MHD_EXTERN int MHD_set_response_options(struct MHD_Response *response, enum MHD_ResponseFlags flags,...)
Definition: response.c:283
_MHD_EXTERN int MHD_get_connection_values(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
Definition: connection.c:127
_MHD_EXTERN int MHD_run(struct MHD_Daemon *daemon)
Definition: daemon.c:2906
MHD_OPTION
MHD options.
Definition: microhttpd.h:671
void * apc_cls
Definition: internal.h:1010
#define MHD_get_fdset(daemon, read_fd_set, write_fd_set, except_fd_set, max_fd)
Definition: microhttpd.h:1711
MHD_ContentReaderCallback crc
Definition: internal.h:272
void * crc_cls
Definition: internal.h:266
MHD_DaemonInfoType
Definition: microhttpd.h:1243
_MHD_EXTERN int MHD_is_feature_supported(enum MHD_FEATURE feature)
Definition: daemon.c:4743
struct sockaddr * client_addr
Definition: microhttpd.h:1153
_MHD_EXTERN int MHD_del_response_header(struct MHD_Response *response, const char *header, const char *content)
Definition: response.c:143
#define _MHD_DEPR_MACRO(msg)
Definition: microhttpd.h:227
_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:712
MHD_ResponseFlags
Definition: microhttpd.h:1952
_MHD_EXTERN const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
Definition: response.c:213
_MHD_EXTERN MHD_socket MHD_quiesce_daemon(struct MHD_Daemon *daemon)
Definition: daemon.c:3034
unsigned int num_connections
Definition: microhttpd.h:2642
int(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Definition: microhttpd.h:1300
void(* MHD_NotifyConnectionCallback)(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
Definition: microhttpd.h:1393
_MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info(struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type,...)
Definition: daemon.c:4642
_MHD_EXTERN size_t MHD_http_unescape(char *val)
Definition: internal.c:132
enum MHD_OPTION option
Definition: microhttpd.h:975
struct MHD_Response * MHD_create_response_from_fd_at_offset(size_t size, int fd, off_t offset)
Definition: response.c:396
_MHD_EXTERN int MHD_set_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value)
Definition: connection.c:179
MHD_FLAG
Flags for the struct MHD_Daemon.
Definition: microhttpd.h:513
_MHD_EXTERN int MHD_get_response_headers(struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)
Definition: response.c:186
MHD_ResponseMemoryMode
Definition: microhttpd.h:2045
_MHD_EXTERN void MHD_resume_connection(struct MHD_Connection *connection)
Definition: daemon.c:1742