GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
internal.h
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4 Copyright (C) 2014-2021 Evgeny Grin (Karlson2k)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
29#ifndef INTERNAL_H
30#define INTERNAL_H
31
32#include "mhd_options.h"
33#include "platform.h"
34#include "microhttpd.h"
35#include "mhd_assert.h"
36
37#ifdef HTTPS_SUPPORT
38#include <gnutls/gnutls.h>
39#if GNUTLS_VERSION_MAJOR >= 3
40#include <gnutls/abstract.h>
41#endif
42#endif /* HTTPS_SUPPORT */
43
44#ifdef HAVE_STDBOOL_H
45#include <stdbool.h>
46#endif
47
48#ifdef HAVE_INTTYPES_H
49#include <inttypes.h>
50#endif /* HAVE_INTTYPES_H */
51
52#ifndef PRIu64
53#define PRIu64 "llu"
54#endif /* ! PRIu64 */
55
56#ifdef MHD_PANIC
57/* Override any defined MHD_PANIC macro with proper one */
58#undef MHD_PANIC
59#endif /* MHD_PANIC */
60
61#ifdef HAVE_MESSAGES
67#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); \
68 BUILTIN_NOT_REACHED; } while (0)
69#else
75#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); \
76 BUILTIN_NOT_REACHED; } while (0)
77#endif
78
79#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
80#include "mhd_threads.h"
81#endif
82#include "mhd_locks.h"
83#include "mhd_sockets.h"
84#include "mhd_itc_types.h"
85
86
91#define _MHD_MACRO_NO 0
92
97#define _MHD_MACRO_YES 1
98
103#define MHD_fd_close_chk_(fd) do { \
104 if ( (0 != close ((fd)) && (EBADF == errno)) ) { \
105 MHD_PANIC (_ ("Failed to close FD.\n")); \
106 } \
107} while (0)
108
109/*
110#define EXTRA_CHECKS _MHD_MACRO_NO
111 * Not used. Behaviour is controlled by _DEBUG/NDEBUG macros.
112 */
113
114#ifndef _MHD_DEBUG_CONNECT
119#define _MHD_DEBUG_CONNECT _MHD_MACRO_NO
120#endif /* ! _MHD_DEBUG_CONNECT */
121
122#ifndef _MHD_DEBUG_SEND_DATA
126#define _MHD_DEBUG_SEND_DATA _MHD_MACRO_NO
127#endif /* ! _MHD_DEBUG_SEND_DATA */
128
129#ifndef _MHD_DEBUG_CLOSE
134#define _MHD_DEBUG_CLOSE _MHD_MACRO_NO
135#endif /* ! _MHD_DEBUG_CLOSE */
136
137#define MHD_MAX(a,b) (((a)<(b)) ? (b) : (a))
138#define MHD_MIN(a,b) (((a)<(b)) ? (a) : (b))
139
140
148#define MHD_BUF_INC_SIZE 1024
149
150
155
159extern void *mhd_panic_cls;
160
161/* If we have Clang or gcc >= 4.5, use __builtin_unreachable() */
162#if defined(__clang__) || (__GNUC__ > 4) || \
163 (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
164#define BUILTIN_NOT_REACHED __builtin_unreachable ()
165#elif defined(_MSC_FULL_VER)
166#define BUILTIN_NOT_REACHED __assume (0)
167#else
168#define BUILTIN_NOT_REACHED
169#endif
170
171#ifndef MHD_STATICSTR_LEN_
175#define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1)
176#endif /* ! MHD_STATICSTR_LEN_ */
177
178
183{
185 _MHD_OFF = false,
186 _MHD_NO = false,
187 _MHD_ON = true,
188 _MHD_YES = true
190
191
196{
197
203
209
215
220
225
230
236
237
242{
247
252
257
263
264
269#define MHD_TEST_ALLOW_SUSPEND_RESUME 8192
270
277#define MAX_NONCE_LENGTH 129
278
279
285{
286
291 uint64_t nc;
292
297 uint64_t nmask;
298
303
304};
305
306#ifdef HAVE_MESSAGES
311void
312MHD_DLOG (const struct MHD_Daemon *daemon,
313 const char *format,
314 ...);
315
316#endif
317
318
322struct MHD_HTTP_Header
323{
327 struct MHD_HTTP_Header *next;
328
333
337 char *header;
338
343
347 char *value;
348
353
358 enum MHD_ValueKind kind;
359
360};
361
362
367{
372 MHD_RAF_HAS_DATE_HDR = 1 << 3
374
375
376#if defined(MHD_WINSOCK_SOCKETS)
381typedef struct _MHD_W32_iovec
382{
383 unsigned long iov_len;
384 char *iov_base;
385} MHD_iovec_;
386#define MHD_IOV_ELMN_MAX_SIZE ULONG_MAX
387typedef unsigned long MHD_iov_size_;
388#elif defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
393typedef struct iovec MHD_iovec_;
394#define MHD_IOV_ELMN_MAX_SIZE SIZE_MAX
395typedef size_t MHD_iov_size_;
396#else
401typedef struct MHD_IoVec MHD_iovec_;
402#define MHD_IOV_ELMN_MAX_SIZE SIZE_MAX
403typedef size_t MHD_iov_size_;
404#endif
405
406
408{
415
420 size_t cnt;
421
427 size_t sent;
428};
429
433struct MHD_Response
434{
435
440
445
450 char *data;
451
456 void *crc_cls;
457
463
469
470#ifdef UPGRADE_SUPPORT
476 MHD_UpgradeHandler upgrade_handler;
477
481 void *upgrade_handler_cls;
482#endif /* UPGRADE_SUPPORT */
483
484#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
489 MHD_mutex_ mutex;
490#endif
491
496 uint64_t total_size;
497
502 uint64_t data_start;
503
507 uint64_t fd_off;
508
513 size_t data_size;
514
518 size_t data_buffer_size;
519
524 unsigned int reference_count;
525
529 int fd;
530
535
540
545
550
554 unsigned int data_iovcnt;
555};
556
557
574{
580
586
591
596
601
606
611
616
621
627
632
638
645
651
656
662
667
672
677
682
687
692
697
698#ifdef UPGRADE_SUPPORT
703 MHD_CONNECTION_UPGRADE
704#endif /* UPGRADE_SUPPORT */
705
707
708
713{
725
729#define DEBUG_STATES _MHD_MACRO_NO
730
731
732#ifdef HAVE_MESSAGES
733#if DEBUG_STATES
734const char *
735MHD_state_to_string (enum MHD_CONNECTION_STATE state);
736
737#endif
738#endif
739
748typedef ssize_t
749(*ReceiveCallback) (struct MHD_Connection *conn,
750 void *write_to,
751 size_t max_bytes);
752
753
762typedef ssize_t
763(*TransmitCallback) (struct MHD_Connection *conn,
764 const void *read_from,
765 size_t max_bytes);
766
767
772{
777
782
787
793
795{
800
805
810
815
820
825
831
835#define MHD_IS_HTTP_VER_SUPPORTED(ver) (MHD_HTTP_VER_1_0 <= (ver) && \
836 MHD_HTTP_VER_1_2__1_9 >= (ver))
837
844#define MHD_IS_HTTP_VER_1_1_COMPAT(ver) (MHD_HTTP_VER_1_1 == (ver) || \
845 MHD_HTTP_VER_1_2__1_9 == (ver))
846
853{
895
896
901{
902 bool set;
905 bool chunked;
906};
907
911struct MHD_Connection
912{
913
914#ifdef EPOLL_SUPPORT
918 struct MHD_Connection *nextE;
919
923 struct MHD_Connection *prevE;
924#endif
925
929 struct MHD_Connection *next;
930
934 struct MHD_Connection *prev;
935
943 struct MHD_Connection *nextX;
944
948 struct MHD_Connection *prevX;
949
953 struct MHD_Daemon *daemon;
954
959
964
969
978 struct MemoryPool *pool;
979
987
995 void *socket_context;
996
1000 char *method;
1001
1006
1011 const char *url;
1012
1017 char *version;
1018
1023
1030
1037
1043
1050 char *last;
1051
1059 char *colon;
1060
1065 struct sockaddr *addr;
1066
1067#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1072 MHD_thread_handle_ID_ pid;
1073#endif
1074
1081
1087
1092
1097
1103
1109
1115
1122
1130
1131
1132#if defined(_MHD_HAVE_SENDFILE)
1133 enum MHD_resp_sender_
1134 {
1135 MHD_resp_sender_std = 0,
1136 MHD_resp_sender_sendfile
1137 } resp_sender;
1138#endif /* _MHD_HAVE_SENDFILE */
1139
1145
1149 socklen_t addr_len;
1150
1156
1163
1168
1175
1182
1188
1192 bool sk_nonblck;
1193
1198
1203
1208
1215 bool read_closed;
1216
1225
1234
1235#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1239 bool thread_joined;
1240#endif
1241
1247
1252
1253#ifdef EPOLL_SUPPORT
1257 enum MHD_EpollState epoll_state;
1258#endif
1259
1264
1269
1274 unsigned int responseCode;
1275
1280
1292
1301
1307
1312
1313#ifdef UPGRADE_SUPPORT
1320 struct MHD_UpgradeResponseHandle *urh;
1321#endif /* UPGRADE_SUPPORT */
1322
1323#ifdef HTTPS_SUPPORT
1324
1328 gnutls_session_t tls_session;
1329
1333 int protocol;
1334
1338 int cipher;
1339
1343 enum MHD_TLS_CONN_STATE tls_state;
1344
1349 bool tls_read_ready;
1350#endif /* HTTPS_SUPPORT */
1351
1355 bool suspended;
1356
1361
1365 volatile bool resuming;
1366};
1367
1368
1369#ifdef UPGRADE_SUPPORT
1379#define RESERVE_EBUF_SIZE 8
1380
1387struct UpgradeEpollHandle
1388{
1393 struct MHD_UpgradeResponseHandle *urh;
1394
1410 MHD_socket socket;
1411
1415 enum MHD_EpollState celi;
1416
1417};
1418
1419
1425struct MHD_UpgradeResponseHandle
1426{
1432 struct MHD_Connection *connection;
1433
1434#ifdef HTTPS_SUPPORT
1438 struct MHD_UpgradeResponseHandle *next;
1439
1443 struct MHD_UpgradeResponseHandle *prev;
1444
1445#ifdef EPOLL_SUPPORT
1449 struct MHD_UpgradeResponseHandle *nextE;
1450
1454 struct MHD_UpgradeResponseHandle *prevE;
1455
1459 bool in_eready_list;
1460#endif
1461
1467 char *in_buffer;
1468
1474 char *out_buffer;
1475
1481 size_t in_buffer_size;
1482
1488 size_t out_buffer_size;
1489
1497 size_t in_buffer_used;
1498
1506 size_t out_buffer_used;
1507
1511 struct UpgradeEpollHandle app;
1512
1517 struct UpgradeEpollHandle mhd;
1518
1523 char e_buf[RESERVE_EBUF_SIZE];
1524
1525#endif /* HTTPS_SUPPORT */
1526
1537 volatile bool was_closed;
1538
1560 volatile bool clean_ready;
1561};
1562#endif /* UPGRADE_SUPPORT */
1563
1564
1573typedef void *
1574(*LogCallback)(void *cls,
1575 const char *uri,
1576 struct MHD_Connection *con);
1577
1587typedef size_t
1588(*UnescapeCallback)(void *cls,
1589 struct MHD_Connection *conn,
1590 char *uri);
1591
1592
1600struct MHD_Daemon
1601{
1602
1607
1612
1620
1625
1630
1635
1640
1645
1650
1655
1660
1665
1666#ifdef EPOLL_SUPPORT
1670 struct MHD_Connection *eready_head;
1671
1675 struct MHD_Connection *eready_tail;
1676
1683 int epoll_fd;
1684
1689 bool listen_socket_in_epoll;
1690
1691#ifdef UPGRADE_SUPPORT
1692#ifdef HTTPS_SUPPORT
1697 int epoll_upgrade_fd;
1698
1703 bool upgrade_fd_in_epoll;
1704#endif /* HTTPS_SUPPORT */
1705
1709 struct MHD_UpgradeResponseHandle *eready_urh_head;
1710
1714 struct MHD_UpgradeResponseHandle *eready_urh_tail;
1715#endif /* UPGRADE_SUPPORT */
1716#endif /* EPOLL_SUPPORT */
1717
1733
1740
1748
1755
1761
1765 void *apc_cls;
1766
1772
1777
1783
1788
1797
1802
1807
1812
1819 uint16_t port;
1820
1821#ifdef HAVE_MESSAGES
1826 MHD_LogCallback custom_error_log;
1827
1831 void *custom_error_log_cls;
1832#endif
1833
1837 struct MHD_Daemon *master;
1838
1846
1851
1852#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1856 struct MHD_Daemon *worker_pool;
1857#endif
1858
1863
1870 unsigned int connections;
1871
1876
1881
1882#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1886 size_t thread_stack_size;
1887
1891 unsigned int worker_pool_size;
1892
1896 MHD_thread_handle_ID_ pid;
1897
1901 MHD_mutex_ per_ip_connection_mutex;
1902
1907 MHD_mutex_ cleanup_connection_mutex;
1908
1912 MHD_mutex_ new_connections_mutex;
1913#endif
1914
1920
1931
1932
1937 struct MHD_itc_ itc;
1938
1942 volatile bool shutdown;
1943
1949 volatile bool was_quiesced;
1950
1958 bool at_limit;
1959
1960 /*
1961 * Do we need to process resuming connections?
1962 */
1963 volatile bool resuming;
1964
1969 volatile bool have_new;
1970
1981
1985 unsigned int connection_limit;
1986
1993
1999
2004
2009
2010#ifdef HTTPS_SUPPORT
2011#ifdef UPGRADE_SUPPORT
2017 struct MHD_UpgradeResponseHandle *urh_head;
2018
2024 struct MHD_UpgradeResponseHandle *urh_tail;
2025#endif /* UPGRADE_SUPPORT */
2026
2030 gnutls_priority_t priority_cache;
2031
2036 gnutls_credentials_type_t cred_type;
2037
2041 gnutls_certificate_credentials_t x509_cred;
2042
2046 gnutls_dh_params_t dh_params;
2047
2051 gnutls_psk_server_credentials_t psk_cred;
2052
2053#if GNUTLS_VERSION_MAJOR >= 3
2058 gnutls_certificate_retrieve_function2 *cert_callback;
2059
2064
2068 void *cred_callback_cls;
2069#endif
2070
2071#if GNUTLS_VERSION_NUMBER >= 0x030603
2076 gnutls_certificate_retrieve_function3 *cert_callback2;
2077#endif
2078
2082 const char *https_mem_key;
2083
2087 const char *https_mem_cert;
2088
2092 const char *https_key_password;
2093
2097 const char *https_mem_trust;
2098
2102 gnutls_dh_params_t https_mem_dhparams;
2103
2107 bool have_dhparams;
2108
2112 bool disable_alpn;
2113
2114 #endif /* HTTPS_SUPPORT */
2115
2116#ifdef DAUTH_SUPPORT
2117
2121 const char *digest_auth_random;
2122
2126 struct MHD_NonceNc *nnc;
2127
2128#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
2132 MHD_mutex_ nnc_lock;
2133#endif
2134
2138 size_t digest_auth_rand_size;
2139
2143 unsigned int nonce_nc_size;
2144
2145#endif
2146
2147#ifdef TCP_FASTOPEN
2151 unsigned int fastopen_queue_size;
2152#endif
2153
2158
2166 size_t num_opts;
2167};
2168
2169
2178#define DLL_insert(head,tail,element) do { \
2179 mhd_assert (NULL == (element)->next); \
2180 mhd_assert (NULL == (element)->prev); \
2181 (element)->next = (head); \
2182 (element)->prev = NULL; \
2183 if ((tail) == NULL) { \
2184 (tail) = element; \
2185 } else { \
2186 (head)->prev = element; \
2187 } \
2188 (head) = (element); } while (0)
2189
2190
2200#define DLL_remove(head,tail,element) do { \
2201 mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \
2202 mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \
2203 if ((element)->prev == NULL) { \
2204 (head) = (element)->next; \
2205 } else { \
2206 (element)->prev->next = (element)->next; \
2207 } \
2208 if ((element)->next == NULL) { \
2209 (tail) = (element)->prev; \
2210 } else { \
2211 (element)->next->prev = (element)->prev; \
2212 } \
2213 (element)->next = NULL; \
2214 (element)->prev = NULL; } while (0)
2215
2216
2225#define XDLL_insert(head,tail,element) do { \
2226 mhd_assert (NULL == (element)->nextX); \
2227 mhd_assert (NULL == (element)->prevX); \
2228 (element)->nextX = (head); \
2229 (element)->prevX = NULL; \
2230 if (NULL == (tail)) { \
2231 (tail) = element; \
2232 } else { \
2233 (head)->prevX = element; \
2234 } \
2235 (head) = (element); } while (0)
2236
2237
2247#define XDLL_remove(head,tail,element) do { \
2248 mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \
2249 mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \
2250 if (NULL == (element)->prevX) { \
2251 (head) = (element)->nextX; \
2252 } else { \
2253 (element)->prevX->nextX = (element)->nextX; \
2254 } \
2255 if (NULL == (element)->nextX) { \
2256 (tail) = (element)->prevX; \
2257 } else { \
2258 (element)->nextX->prevX = (element)->prevX; \
2259 } \
2260 (element)->nextX = NULL; \
2261 (element)->prevX = NULL; } while (0)
2262
2263
2272#define EDLL_insert(head,tail,element) do { \
2273 (element)->nextE = (head); \
2274 (element)->prevE = NULL; \
2275 if ((tail) == NULL) { \
2276 (tail) = element; \
2277 } else { \
2278 (head)->prevE = element; \
2279 } \
2280 (head) = (element); } while (0)
2281
2282
2292#define EDLL_remove(head,tail,element) do { \
2293 if ((element)->prevE == NULL) { \
2294 (head) = (element)->nextE; \
2295 } else { \
2296 (element)->prevE->nextE = (element)->nextE; \
2297 } \
2298 if ((element)->nextE == NULL) { \
2299 (tail) = (element)->prevE; \
2300 } else { \
2301 (element)->nextE->prevE = (element)->prevE; \
2302 } \
2303 (element)->nextE = NULL; \
2304 (element)->prevE = NULL; } while (0)
2305
2306
2312void
2314
2315
2329typedef enum MHD_Result
2330(*MHD_ArgumentIterator_)(struct MHD_Connection *connection,
2331 const char *key,
2332 size_t key_size,
2333 const char *value,
2334 size_t value_size,
2335 enum MHD_ValueKind kind);
2336
2337
2352enum MHD_Result
2353MHD_parse_arguments_ (struct MHD_Connection *connection,
2354 enum MHD_ValueKind kind,
2355 char *args,
2357 unsigned int *num_headers);
2358
2359
2376bool
2378 const char *key,
2379 size_t key_len,
2380 const char *token,
2381 size_t token_len);
2382
2394#define MHD_check_response_header_s_token_ci(r,k,tkn) \
2395 MHD_check_response_header_token_ci ((r),(k),MHD_STATICSTR_LEN_ (k), \
2396 (tkn),MHD_STATICSTR_LEN_ (tkn))
2397
2405struct MHD_Daemon *
2406MHD_get_master (struct MHD_Daemon *daemon);
2407
2417void
2418internal_suspend_connection_ (struct MHD_Connection *connection);
2419
2420
2421#ifdef UPGRADE_SUPPORT
2429void
2430MHD_upgraded_connection_mark_app_closed_ (struct MHD_Connection *connection);
2431
2432#endif /* UPGRADE_SUPPORT */
2433
2434
2435#endif
void(* MHD_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
void(* MHD_LogCallback)(void *cls, const char *fm, va_list ap)
void(* MHD_NotifyConnectionCallback)(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
void(* MHD_ContentReaderFreeCallback)(void *cls)
MHD_PanicCallback mhd_panic
Definition panic.c:31
ssize_t(* TransmitCallback)(struct MHD_Connection *conn, const void *read_from, size_t max_bytes)
Definition internal.h:196
MHD_EpollState
Definition internal.h:588
@ MHD_EPOLL_STATE_SUSPENDED
Definition internal.h:621
@ MHD_EPOLL_STATE_IN_EREADY_EDLL
Definition internal.h:611
@ MHD_EPOLL_STATE_READ_READY
Definition internal.h:600
@ MHD_EPOLL_STATE_IN_EPOLL_SET
Definition internal.h:616
@ MHD_EPOLL_STATE_UNREADY
Definition internal.h:594
@ MHD_EPOLL_STATE_WRITE_READY
Definition internal.h:606
@ MHD_EPOLL_STATE_ERROR
Definition internal.h:626
bool(* MHD_ArgumentIterator_)(struct MHD_Request *request, const char *key, const char *value, enum MHD_ValueKind kind)
Definition internal.h:1707
MHD_ConnKeepAlive
Definition internal.h:155
@ MHD_CONN_USE_KEEPALIVE
Definition internal.h:169
@ MHD_CONN_MUST_CLOSE
Definition internal.h:159
@ MHD_CONN_KEEPALIVE_UNKOWN
Definition internal.h:164
ssize_t(* ReceiveCallback)(struct MHD_Connection *conn, void *write_to, size_t max_bytes)
Definition internal.h:182
bool MHD_parse_arguments_(struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
Definition internal.c:190
void * mhd_panic_cls
Definition panic.c:36
additional automatic macros for MHD_config.h
MHD_CONNECTION_STATE
Definition internal.h:574
@ MHD_CONNECTION_BODY_RECEIVED
Definition internal.h:620
@ MHD_CONNECTION_HEADER_PART_RECEIVED
Definition internal.h:595
@ MHD_CONNECTION_HEADERS_SENDING
Definition internal.h:650
@ MHD_CONNECTION_FOOTERS_SENDING
Definition internal.h:686
@ MHD_CONNECTION_FOOTERS_RECEIVED
Definition internal.h:631
@ MHD_CONNECTION_HEADERS_SENT
Definition internal.h:655
@ MHD_CONNECTION_HEADERS_PROCESSED
Definition internal.h:605
@ MHD_CONNECTION_INIT
Definition internal.h:579
@ MHD_CONNECTION_CLOSED
Definition internal.h:696
@ MHD_CONNECTION_NORMAL_BODY_UNREADY
Definition internal.h:661
@ MHD_CONNECTION_HEADERS_RECEIVED
Definition internal.h:600
@ MHD_CONNECTION_NORMAL_BODY_READY
Definition internal.h:666
@ MHD_CONNECTION_START_REPLY
Definition internal.h:644
@ MHD_CONNECTION_CHUNKED_BODY_READY
Definition internal.h:676
@ MHD_CONNECTION_FOOTER_PART_RECEIVED
Definition internal.h:626
@ MHD_CONNECTION_CONTINUE_SENT
Definition internal.h:615
@ MHD_CONNECTION_FOOTERS_SENT
Definition internal.h:691
@ MHD_CONNECTION_FULL_REQ_RECEIVED
Definition internal.h:637
@ MHD_CONNECTION_CHUNKED_BODY_UNREADY
Definition internal.h:671
@ MHD_CONNECTION_BODY_SENT
Definition internal.h:681
@ MHD_CONNECTION_CONTINUE_SENDING
Definition internal.h:610
@ MHD_CONNECTION_URL_RECEIVED
Definition internal.h:590
@ MHD_CONNECTION_REQ_LINE_RECEIVING
Definition internal.h:585
bool MHD_check_response_header_token_ci(const struct MHD_Response *response, const char *key, size_t key_len, const char *token, size_t token_len)
Definition response.c:773
MHD_EpollState
Definition internal.h:196
void internal_suspend_connection_(struct MHD_Connection *connection)
Definition daemon.c:3110
MHD_TLS_CONN_STATE
Definition internal.h:713
@ MHD_TLS_CONN_TLS_CLOSING
Definition internal.h:720
@ MHD_TLS_CONN_WR_CLOSING
Definition internal.h:718
@ MHD_TLS_CONN_INVALID_STATE
Definition internal.h:723
@ MHD_TLS_CONN_WR_CLOSED
Definition internal.h:719
@ MHD_TLS_CONN_NO_TLS
Definition internal.h:714
@ MHD_TLS_CONN_INIT
Definition internal.h:715
@ MHD_TLS_CONN_TLS_CLOSED
Definition internal.h:721
@ MHD_TLS_CONN_TLS_FAILED
Definition internal.h:722
@ MHD_TLS_CONN_CONNECTED
Definition internal.h:717
@ MHD_TLS_CONN_HANDSHAKING
Definition internal.h:716
MHD_ConnectionEventLoopInfo
Definition internal.h:242
@ MHD_EVENT_LOOP_INFO_READ
Definition internal.h:246
@ MHD_EVENT_LOOP_INFO_WRITE
Definition internal.h:251
@ MHD_EVENT_LOOP_INFO_CLEANUP
Definition internal.h:261
@ MHD_EVENT_LOOP_INFO_BLOCK
Definition internal.h:256
struct MHD_IoVec MHD_iovec_
Definition internal.h:401
size_t MHD_iov_size_
Definition internal.h:403
void *(* LogCallback)(void *cls, const char *uri, struct MHD_Connection *con)
Definition internal.h:1574
MHD_ResponseAutoFlags
Definition internal.h:367
@ MHD_RAF_HAS_DATE_HDR
Definition internal.h:372
@ MHD_RAF_NO_FLAGS
Definition internal.h:368
@ MHD_RAF_HAS_CONNECTION_CLOSE
Definition internal.h:370
@ MHD_RAF_HAS_TRANS_ENC_CHUNKED
Definition internal.h:371
@ MHD_RAF_HAS_CONNECTION_HDR
Definition internal.h:369
struct MHD_Daemon * MHD_get_master(struct MHD_Daemon *daemon)
Definition daemon.c:261
MHD_HTTP_Version
Definition internal.h:795
@ MHD_HTTP_VER_1_0
Definition internal.h:814
@ MHD_HTTP_VER_1_1
Definition internal.h:819
@ MHD_HTTP_VER_TOO_OLD
Definition internal.h:809
@ MHD_HTTP_VER_INVALID
Definition internal.h:799
@ MHD_HTTP_VER_UNKNOWN
Definition internal.h:804
@ MHD_HTTP_VER_1_2__1_9
Definition internal.h:824
@ MHD_HTTP_VER_FUTURE
Definition internal.h:829
MHD_ConnKeepAlive
Definition internal.h:772
@ MHD_CONN_MUST_UPGRADE
Definition internal.h:791
ssize_t(* ReceiveCallback)(struct MHD_Connection *conn, void *write_to, size_t max_bytes)
Definition internal.h:749
#define MAX_NONCE_LENGTH
Definition internal.h:277
void MHD_unescape_plus(char *arg)
Definition internal.c:123
enum MHD_EpollState _MHD_FIXED_FLAGS_ENUM
MHD_HTTP_Method
Definition internal.h:853
@ MHD_HTTP_MTHD_GET
Definition internal.h:861
@ MHD_HTTP_MTHD_CONNECT
Definition internal.h:881
@ MHD_HTTP_MTHD_DELETE
Definition internal.h:877
@ MHD_HTTP_MTHD_OPTIONS
Definition internal.h:885
@ MHD_HTTP_MTHD_TRACE
Definition internal.h:889
@ MHD_HTTP_MTHD_HEAD
Definition internal.h:865
@ MHD_HTTP_MTHD_POST
Definition internal.h:869
@ MHD_HTTP_MTHD_OTHER
Definition internal.h:893
@ MHD_HTTP_MTHD_NO_METHOD
Definition internal.h:857
@ MHD_HTTP_MTHD_PUT
Definition internal.h:873
enum MHD_tristate _MHD_FIXED_ENUM
size_t(* UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri)
Definition internal.h:1588
MHD_tristate
Definition internal.h:183
@ _MHD_ON
Definition internal.h:187
@ _MHD_UNKNOWN
Definition internal.h:184
@ _MHD_YES
Definition internal.h:188
@ _MHD_OFF
Definition internal.h:185
@ _MHD_NO
Definition internal.h:186
macros for mhd_assert()
Types for platform-independent inter-thread communication.
Header for platform-independent locks abstraction.
public interface to libmicrohttpd
int MHD_socket
Definition microhttpd.h:207
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)
MHD_DisableSanityCheck
MHD_Result
Definition microhttpd.h:158
enum MHD_Result(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
enum MHD_Result(* 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)
MHD_ValueKind
int(* MHD_PskServerCredentialsCallback)(void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size)
MHD_FLAG
Flags for the struct MHD_Daemon.
MHD_ResponseFlags
platform-specific includes for libmicrohttpd
MHD_socket socket_fd
Definition internal.h:752
enum MHD_HTTP_Method http_mthd
Definition internal.h:1005
enum MHD_tristate sk_nodelay
Definition internal.h:1207
size_t write_buffer_size
Definition internal.h:1091
size_t write_buffer_send_offset
Definition internal.h:1096
struct MHD_Connection * prevX
Definition internal.h:670
struct MHD_Reply_Properties rp_props
Definition internal.h:1279
socklen_t addr_len
Definition internal.h:733
enum MHD_HTTP_Version http_ver
Definition internal.h:1022
enum MHD_ConnectionEventLoopInfo event_loop_info
Definition internal.h:1268
size_t write_buffer_append_offset
Definition internal.h:1102
enum MHD_tristate is_nonip
Definition internal.h:1187
char * write_buffer
Definition internal.h:1042
bool stop_with_error
Definition internal.h:1224
bool tls_read_ready
Definition internal.h:769
uint64_t remaining_upload_size
Definition internal.h:1114
void * socket_context
Definition internal.h:694
bool discard_request
Definition internal.h:1233
ReceiveCallback recv_cls
Definition internal.h:706
volatile bool resuming
Definition internal.h:1365
size_t header_size
Definition internal.h:1108
uint64_t last_activity
Definition internal.h:1155
struct MHD_Response * response
Definition internal.h:968
const char * url
Definition internal.h:1011
struct MHD_Connection * next
Definition internal.h:651
enum MHD_ConnKeepAlive keepalive
Definition internal.h:1029
struct MHD_HTTP_Header * headers_received
Definition internal.h:958
size_t continue_message_write_offset
Definition internal.h:1144
uint64_t response_write_position
Definition internal.h:1121
struct MHD_HTTP_Header * headers_received_tail
Definition internal.h:963
uint64_t current_chunk_offset
Definition internal.h:1306
struct MemoryPool * pool
Definition internal.h:685
size_t read_buffer_offset
Definition internal.h:1086
struct MHD_Connection * prev
Definition internal.h:656
uint64_t current_chunk_size
Definition internal.h:1300
struct MHD_iovec_track_ resp_iov
Definition internal.h:1129
unsigned int responseCode
Definition internal.h:1274
MHD_thread_handle_ID_ pid
Definition internal.h:723
struct MHD_Connection * nextX
Definition internal.h:665
bool have_chunked_upload
Definition internal.h:1291
void * client_context
Definition internal.h:986
enum MHD_CONNECTION_STATE state
Definition internal.h:1263
char * read_buffer
Definition internal.h:1036
struct sockaddr * addr
Definition internal.h:1065
struct MHD_Daemon * daemon
Definition internal.h:675
unsigned int connection_timeout_dummy
Definition internal.h:1167
bool sk_spipe_suppress
Definition internal.h:1197
uint64_t connection_timeout_ms
Definition internal.h:1162
size_t read_buffer_size
Definition internal.h:1080
enum MHD_tristate sk_corked
Definition internal.h:1202
bool thread_joined
Definition internal.h:779
size_t pool_size
Definition internal.h:1875
MHD_NotifyConnectionCallback notify_connection
Definition internal.h:1782
MHD_AccessHandlerCallback default_handler
Definition internal.h:1606
LogCallback uri_log_callback
Definition internal.h:1796
bool data_already_pending
Definition internal.h:1500
MHD_mutex_ per_ip_connection_mutex
Definition internal.h:1259
void * per_ip_connection_count
Definition internal.h:1187
bool at_limit
Definition internal.h:1483
struct MHD_Connection * new_connections_tail
Definition internal.h:1629
uint16_t port
Definition internal.h:1819
bool listen_nonblk
Definition internal.h:1850
unsigned int connection_limit
Definition internal.h:1985
void * unescape_callback_cls
Definition internal.h:1811
MHD_mutex_ cleanup_connection_mutex
Definition internal.h:1265
enum MHD_DisableSanityCheck insanity_level
Definition internal.h:1919
struct MHD_Connection * connections_head
Definition internal.h:1155
unsigned int listen_backlog_size
Definition internal.h:2157
MHD_RequestCompletedCallback notify_completed
Definition internal.h:1771
unsigned int worker_pool_size
Definition internal.h:1366
unsigned int connections
Definition internal.h:1361
struct MHD_itc_ itc
Definition internal.h:1410
int listening_address_reuse
Definition internal.h:1930
uint64_t connection_timeout_ms
Definition internal.h:1992
void * apc_cls
Definition internal.h:1765
unsigned int per_ip_connection_limit
Definition internal.h:1998
struct MHD_Connection * manual_timeout_tail
Definition internal.h:1150
volatile bool shutdown
Definition internal.h:1526
enum MHD_FLAG options
Definition internal.h:1619
void * notify_connection_cls
Definition internal.h:1787
bool sigpipe_blocked
Definition internal.h:2008
UnescapeCallback unescape_callback
Definition internal.h:1806
void * notify_completed_cls
Definition internal.h:1776
struct MHD_Connection * cleanup_tail
Definition internal.h:1182
volatile bool was_quiesced
Definition internal.h:1949
size_t num_opts
Definition internal.h:2166
struct MHD_Daemon * worker_pool
Definition internal.h:1073
struct MHD_Connection * new_connections_head
Definition internal.h:1624
MHD_thread_handle_ID_ pid
Definition internal.h:1249
struct MHD_Connection * manual_timeout_head
Definition internal.h:1143
enum MHD_tristate listen_is_unix
Definition internal.h:1664
volatile bool resuming
Definition internal.h:1963
void * default_handler_cls
Definition internal.h:1611
struct MHD_Connection * suspended_connections_tail
Definition internal.h:1172
MHD_AcceptPolicyCallback apc
Definition internal.h:1760
struct MHD_Connection * cleanup_head
Definition internal.h:1177
struct MHD_Daemon * master
Definition internal.h:1068
struct MHD_Connection * normal_timeout_head
Definition internal.h:1128
struct MHD_Connection * normal_timeout_tail
Definition internal.h:1135
volatile bool have_new
Definition internal.h:1969
size_t pool_increment
Definition internal.h:1880
MHD_socket listen_fd
Definition internal.h:1845
void * uri_log_callback_cls
Definition internal.h:1801
struct MHD_Connection * suspended_connections_head
Definition internal.h:1166
struct MHD_Connection * connections_tail
Definition internal.h:1160
int strict_for_client
Definition internal.h:2003
size_t value_size
Definition internal.h:352
struct MHD_HTTP_Header * prev
Definition internal.h:332
enum MHD_ValueKind kind
Definition internal.h:358
size_t header_size
Definition internal.h:342
struct MHD_HTTP_Header * next
Definition internal.h:342
uint64_t nc
Definition internal.h:291
uint64_t nmask
Definition internal.h:297
char nonce[MAX_NONCE_LENGTH]
Definition internal.h:302
MHD_ContentReaderFreeCallback crfc
Definition internal.h:1606
struct MHD_HTTP_Header * first_header
Definition internal.h:1582
void * crc_cls
Definition internal.h:1594
size_t data_buffer_size
Definition internal.h:1664
MHD_iovec_ * data_iov
Definition internal.h:549
uint64_t data_start
Definition internal.h:1648
MHD_ContentReaderCallback crc
Definition internal.h:1600
struct MHD_HTTP_Header * last_header
Definition internal.h:444
enum MHD_ResponseAutoFlags flags_auto
Definition internal.h:539
unsigned int data_iovcnt
Definition internal.h:554
size_t data_size
Definition internal.h:1659
enum MHD_ResponseFlags flags
Definition internal.h:534
unsigned int reference_count
Definition internal.h:1675
char * data
Definition internal.h:1588
MHD_mutex_ mutex
Definition internal.h:1637
uint64_t total_size
Definition internal.h:1642
uint64_t fd_off
Definition internal.h:1653
MHD_iovec_ * iov
Definition internal.h:414