35#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
41#ifdef MHD_LINUX_SOLARIS_SENDFILE
42#include <sys/sendfile.h>
44#if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE)
46#include <sys/socket.h>
52#ifdef HAVE_SYS_PARAM_H
65#define MHD_ALLOW_BARE_LF_AS_CRLF_(discp_lvl) (0 >= discp_lvl)
75#define MHD_CHUNK_HEADER_REASONABLE_LEN 24
80#define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n"
87#define ERR_MSG_REQUEST_TOO_BIG \
89 "<head><title>Request too big</title></head>" \
90 "<body>Request HTTP header is too big for the memory constraints " \
91 "of this webserver.</body>" \
94#define ERR_MSG_REQUEST_TOO_BIG ""
101#define ERR_MSG_REQUEST_HEADER_TOO_BIG \
103 "<head><title>Request too big</title></head>" \
104 "<body><p>The total size of the request headers, which includes the " \
105 "request target and the request field lines, exceeds the memory " \
106 "constraints of this web server.</p>" \
107 "<p>The request could be re-tried with shorter field lines, a shorter " \
108 "request target or a shorter request method token.</p></body>" \
111#define ERR_MSG_REQUEST_HEADER_TOO_BIG ""
118#define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG \
120 "<head><title>Request too big</title></head>" \
121 "<body><p>The total size of the request headers, which includes the " \
122 "request target and the request field lines, exceeds the memory " \
123 "constraints of this web server.</p> " \
124 "<p>The request could be re-tried with smaller " \
125 "<b>"Cookie:"</b> field value, shorter other field lines, " \
126 "a shorter request target or a shorter request method token.</p></body> " \
129#define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG ""
137#define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG \
139 "<head><title>Request too big</title></head>" \
140 "<body><p>The total size of the request target, the request field lines " \
141 "and the chunk size line exceeds the memory constraints of this web " \
143 "<p>The request could be re-tried without chunk extensions, with a smaller " \
144 "chunk size, shorter field lines, a shorter request target or a shorter " \
145 "request method token.</p></body>" \
148#define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG ""
156#define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG \
158 "<head><title>Request too big</title></head>" \
159 "<body><p>The total size of the request target, the request field lines " \
160 "and the chunk size line exceeds the memory constraints of this web " \
162 "<p>The request could be re-tried with a smaller " \
163 "chunk size, shorter field lines, a shorter request target or a shorter " \
164 "request method token.</p></body>" \
167#define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG ""
174#define ERR_MSG_REQUEST_FOOTER_TOO_BIG \
176 "<head><title>Request too big</title></head>" \
177 "<body><p>The total size of the request headers, which includes the " \
178 "request target, the request field lines and the chunked trailer " \
179 "section exceeds the memory constraints of this web server.</p>" \
180 "<p>The request could be re-tried with a shorter chunked trailer " \
181 "section, shorter field lines, a shorter request target or " \
182 "a shorter request method token.</p></body>" \
185#define ERR_MSG_REQUEST_FOOTER_TOO_BIG ""
192#define RQ_LINE_TOO_MANY_WSP \
194 "<head><title>Request broken</title></head>" \
195 "<body>The request line has more then two whitespaces.</body>" \
198#define RQ_LINE_TOO_MANY_WSP ""
206#define BARE_CR_IN_HEADER \
208 "<head><title>Request broken</title></head>" \
209 "<body>Request HTTP header has bare CR character without " \
210 "following LF character.</body>" \
213#define BARE_CR_IN_HEADER ""
221#define BARE_CR_IN_FOOTER \
223 "<head><title>Request broken</title></head>" \
224 "<body>Request HTTP footer has bare CR character without " \
225 "following LF character.</body>" \
228#define BARE_CR_IN_FOOTER ""
236#define BARE_LF_IN_HEADER \
238 "<head><title>Request broken</title></head>" \
239 "<body>Request HTTP header has bare LF character without " \
240 "preceding CR character.</body>" \
243#define BARE_LF_IN_HEADER ""
251#define BARE_LF_IN_FOOTER \
253 "<head><title>Request broken</title></head>" \
254 "<body>Request HTTP footer has bare LF character without " \
255 "preceding CR character.</body>" \
258#define BARE_LF_IN_FOOTER ""
265#define RQ_TARGET_INVALID_CHAR \
267 "<head><title>Request broken</title></head>" \
268 "<body>HTTP request has invalid characters in " \
269 "the request-target.</body>" \
272#define RQ_TARGET_INVALID_CHAR ""
279#define ERR_RSP_OBS_FOLD \
281 "<head><title>Request broken</title></head>" \
282 "<body>Obsolete line folding is used in HTTP request header.</body>" \
285#define ERR_RSP_OBS_FOLD ""
292#define ERR_RSP_OBS_FOLD_FOOTER \
294 "<head><title>Request broken</title></head>" \
295 "<body>Obsolete line folding is used in HTTP request footer.</body>" \
298#define ERR_RSP_OBS_FOLD_FOOTER ""
306#define ERR_RSP_WSP_BEFORE_HEADER \
308 "<head><title>Request broken</title></head>" \
309 "<body>HTTP request has whitespace between the request line and " \
310 "the first header.</body>" \
313#define ERR_RSP_WSP_BEFORE_HEADER ""
321#define ERR_RSP_WSP_BEFORE_FOOTER \
323 "<head><title>Request broken</title></head>" \
324 "<body>First HTTP footer line has whitespace at the first " \
328#define ERR_RSP_WSP_BEFORE_FOOTER ""
336#define ERR_RSP_WSP_IN_HEADER_NAME \
338 "<head><title>Request broken</title></head>" \
339 "<body>HTTP request has whitespace before the first colon " \
340 "in header line.</body>" \
343#define ERR_RSP_WSP_IN_HEADER_NAME ""
351#define ERR_RSP_WSP_IN_FOOTER_NAME \
353 "<head><title>Request broken</title></head>" \
354 "<body>HTTP request has whitespace before the first colon " \
355 "in footer line.</body>" \
358#define ERR_RSP_WSP_IN_FOOTER_NAME ""
365#define ERR_RSP_INVALID_CHR_IN_HEADER \
367 "<head><title>Request broken</title></head>" \
368 "<body>HTTP request has invalid character in header.</body>" \
371#define ERR_RSP_INVALID_CHR_IN_HEADER ""
378#define ERR_RSP_INVALID_CHR_IN_FOOTER \
380 "<head><title>Request broken</title></head>" \
381 "<body>HTTP request has invalid character in footer.</body>" \
384#define ERR_RSP_INVALID_CHR_IN_FOOTER ""
391#define ERR_RSP_HEADER_WITHOUT_COLON \
393 "<head><title>Request broken</title></head>" \
394 "<body>HTTP request header line has no colon character.</body>" \
397#define ERR_RSP_HEADER_WITHOUT_COLON ""
404#define ERR_RSP_FOOTER_WITHOUT_COLON \
406 "<head><title>Request broken</title></head>" \
407 "<body>HTTP request footer line has no colon character.</body>" \
410#define ERR_RSP_FOOTER_WITHOUT_COLON ""
417#define ERR_RSP_EMPTY_HEADER_NAME \
419 "<head><title>Request broken</title></head>" \
420 "<body>HTTP request header has empty header name.</body>" \
423#define ERR_RSP_EMPTY_HEADER_NAME ""
430#define ERR_RSP_EMPTY_FOOTER_NAME \
432 "<head><title>Request broken</title></head>" \
433 "<body>HTTP request footer has empty footer name.</body>" \
436#define ERR_RSP_EMPTY_FOOTER_NAME ""
447#define REQUEST_LACKS_HOST \
449 "<head><title>"Host:" header required</title></head>" \
450 "<body>HTTP/1.1 request without <b>"Host:"</b>.</body>" \
454#define REQUEST_LACKS_HOST ""
461#define REQUEST_UNSUPPORTED_TR_ENCODING \
463 "<head><title>Unsupported Transfer-Encoding</title></head>" \
464 "<body>The Transfer-Encoding used in request is not supported.</body>" \
467#define REQUEST_UNSUPPORTED_TR_ENCODING ""
475#define REQUEST_LENGTH_WITH_TR_ENCODING \
477 "<head><title>Malformed request</title></head>" \
478 "<body>Wrong combination of the request headers: both Transfer-Encoding " \
479 "and Content-Length headers are used at the same time.</body>" \
482#define REQUEST_LENGTH_WITH_TR_ENCODING ""
493#define REQUEST_MALFORMED \
494 "<html><head><title>Request malformed</title></head>" \
495 "<body>HTTP request is syntactically incorrect.</body></html>"
497#define REQUEST_MALFORMED ""
505#define REQUEST_CHUNKED_MALFORMED \
506 "<html><head><title>Request malformed</title></head>" \
507 "<body>HTTP chunked encoding is syntactically incorrect.</body></html>"
509#define REQUEST_CHUNKED_MALFORMED ""
516#define REQUEST_CHUNK_TOO_LARGE \
517 "<html><head><title>Request content too large</title></head>" \
518 "<body>The chunk size used in HTTP chunked encoded " \
519 "request is too large.</body></html>"
521#define REQUEST_CHUNK_TOO_LARGE ""
528#define REQUEST_CONTENTLENGTH_TOOLARGE \
529 "<html><head><title>Request content too large</title></head>" \
530 "<body>HTTP request has too large value for " \
531 "<b>Content-Length</b> header.</body></html>"
533#define REQUEST_CONTENTLENGTH_TOOLARGE ""
541#define REQUEST_CONTENTLENGTH_MALFORMED \
542 "<html><head><title>Request malformed</title></head>" \
543 "<body>HTTP request has wrong value for " \
544 "<b>Content-Length</b> header.</body></html>"
546#define REQUEST_CONTENTLENGTH_MALFORMED ""
556#define ERROR_MSG_DATA_NOT_HANDLED_BY_APP \
557 "<html><head><title>Internal server error</title></head>" \
558 "<body>Please ask the developer of this Web server to carefully " \
559 "read the GNU libmicrohttpd documentation about connection " \
560 "management and blocking.</body></html>"
562#define ERROR_MSG_DATA_NOT_HANDLED_BY_APP ""
569#define REQ_HTTP_VER_IS_TOO_OLD \
570 "<html><head><title>Requested HTTP version is not supported</title></head>" \
571 "<body>Requested HTTP version is too old and not " \
572 "supported.</body></html>"
574#define REQ_HTTP_VER_IS_TOO_OLD ""
581#define REQ_HTTP_VER_IS_NOT_SUPPORTED \
582 "<html><head><title>Requested HTTP version is not supported</title></head>" \
583 "<body>Requested HTTP version is not supported.</body></html>"
585#define REQ_HTTP_VER_IS_NOT_SUPPORTED ""
592#define MHD_SENFILE_CHUNK_ (0x20000)
597#define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000)
606str_conn_error_ (ssize_t mhd_err_code)
608 switch (mhd_err_code)
611 return _ (
"The operation would block, retry later");
613 return _ (
"The connection was forcibly closed by remote peer");
615 return _ (
"The socket is not connected");
617 return _ (
"Not enough system resources to serve the request");
619 return _ (
"Bad FD value");
621 return _ (
"Argument value is invalid");
623 return _ (
"Argument value is not supported");
625 return _ (
"The socket is no longer available for sending");
627 return _ (
"TLS encryption or decryption error");
631 if (0 <= mhd_err_code)
632 return _ (
"Not an error code");
635 return _ (
"Wrong error code value");
655 struct MemoryPool *
const pool = c->
pool;
656 size_t need_to_be_freed = 0;
749 connection->epoll_state &=
772 else if (i > (
size_t) ret)
773 connection->epoll_state &=
801 if (
NULL == connection)
808 if ( (
NULL != iterator) &&
809 (
MHD_NO == iterator (iterator_cls,
840 if (
NULL == connection)
844 if (
NULL == iterator)
855 if (
MHD_NO == iterator (iterator_cls,
953 ( ((key ? strlen (key) : 0) != key_size) ||
1031 (
NULL == key) ? 0 : strlen (key),
1062 const char **value_ptr,
1063 size_t *value_size_ptr)
1067 if (
NULL == connection)
1085 ( (key == pos->
header) ||
1096 if (
NULL != value_ptr)
1097 *value_ptr = pos->
value;
1099 if (
NULL != value_size_ptr)
1131 (
NULL == token) || (0 == token[0]))
1160#define MHD_lookup_header_s_token_ci(c,h,tkn) \
1161 MHD_lookup_header_token_ci ((c),(h),MHD_STATICSTR_LEN_ (h), \
1162 (tkn),MHD_STATICSTR_LEN_ (tkn))
1253#ifdef MHD_USE_THREADS
1279#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
1294 struct MHD_UpgradeResponseHandle *urh = connection->urh;
1296#ifdef MHD_USE_THREADS
1311 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
1316 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
1318 if (urh->in_eready_list)
1321 daemon->eready_urh_tail,
1323 urh->in_eready_list =
false;
1330 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
1335 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
1340 shutdown (urh->mhd.socket, SHUT_RDWR);
1368 MHD_DLOG (connection->
daemon,
1384#define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, emsg)
1386#define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, NULL)
1429 _ (
"Closing connection (out of memory)."));
1446#if defined(_MHD_HAVE_SENDFILE)
1447 if (MHD_resp_sender_sendfile == connection->
rp.resp_sender)
1456 (
char *) response->
data,
1466#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1474 _ (
"Closing connection (application reported " \
1475 "error generating data)."));
1483#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1510 static const size_t max_chunk = 0xFFFFFF;
1513 static const size_t max_chunk_hdr_len =
sizeof(chunk_hdr) + 2;
1515 static const size_t max_chunk_overhead =
sizeof(chunk_hdr) + 2 + 2;
1516 size_t chunk_hdr_len;
1517 uint64_t left_to_send;
1518 size_t size_to_fill;
1533#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1538 _ (
"Closing connection (out of memory)."));
1542 if ( (max_chunk + max_chunk_overhead) < size)
1543 size = max_chunk + max_chunk_overhead;
1556 mhd_assert (max_chunk_overhead < connection->write_buffer_size);
1566 if (max_chunk < size_to_fill)
1567 size_to_fill = max_chunk;
1568 if (left_to_send < size_to_fill)
1569 size_to_fill = (size_t) left_to_send;
1571 if (0 == left_to_send)
1581 const size_t data_write_offset
1587 ret = (ssize_t) (response->
data_size - data_write_offset);
1588 if ( ((
size_t) ret) > size_to_fill)
1589 ret = (ssize_t) size_to_fill;
1591 &response->
data[data_write_offset],
1598#if defined(MHD_USE_THREADS)
1602 _ (
"No callback for the chunked data."));
1615#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1619 _ (
"Closing connection (application error " \
1620 "generating response)."));
1633#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1638 if (size_to_fill < (
size_t) ret)
1640#if defined(MHD_USE_THREADS)
1644 _ (
"Closing connection (application returned " \
1645 "more data than requested)."));
1651 mhd_assert (chunk_hdr_len <
sizeof(chunk_hdr));
1652 *p_finished =
false;
1654 (max_chunk_hdr_len - (chunk_hdr_len + 2));
1658 connection->
write_buffer[max_chunk_hdr_len - 2] =
'\r';
1659 connection->
write_buffer[max_chunk_hdr_len - 1] =
'\n';
1660 connection->
write_buffer[max_chunk_hdr_len + (size_t) ret] =
'\r';
1661 connection->
write_buffer[max_chunk_hdr_len + (size_t) ret + 1] =
'\n';
1700#ifdef UPGRADE_SUPPORT
1703 if (
NULL != r->upgrade_handler)
1761 static const char *
const days[] = {
1762 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
1764 static const char *
const mons[] = {
1765 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
1766 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
1768 static const size_t buf_len = 29;
1772#if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \
1773 ! defined(HAVE_GMTIME_R)
1777 if ((time_t) -1 == time (&t))
1779#if defined(HAVE_C11_GMTIME_S)
1780 if (
NULL == gmtime_s (&t,
1783#elif defined(HAVE_W32_GMTIME_S)
1784 if (0 != gmtime_s (&now,
1787#elif defined(HAVE_GMTIME_R)
1788 if (
NULL == gmtime_r (&t,
1799 src = days[now.tm_wday % 7];
1807 date + 5, buf_len - 5))
1811 src = mons[now.tm_mon % 12];
1886 if (0 == avail_size)
1889 new_size = avail_size / 2;
1894 grow_size = avail_size / 8;
1895 if (def_grow_size > grow_size)
1897 const size_t left_free =
1901 if ((def_grow_size <= grow_size + left_free)
1902 && (left_free < def_grow_size))
1903 grow_size = def_grow_size - left_free;
1904 else if (! required)
1909 const size_t small_inc =
1912 if (small_inc < avail_size)
1913 grow_size = small_inc;
1915 grow_size = avail_size;
2000 struct MemoryPool *
const pool = connection->
pool;
2049connection_shrink_write_buffer (
struct MHD_Connection *connection)
2052 struct MemoryPool *
const pool = connection->
pool;
2156#ifdef UPGRADE_SUPPORT
2167 (2 == rcode / 100) )
2212#ifdef UPGRADE_SUPPORT
2225 use_chunked =
false;
2229 use_chunked =
false;
2239 use_chunked =
false;
2249 use_chunked =
false;
2274 _ (
"This reply with response code %u cannot use reply body. "
2275 "Non-empty response body is ignored and not used.\n"),
2282 _ (
"This reply with response code %u cannot use reply body. "
2283 "Application defined \"Content-Length\" header violates"
2284 "HTTP specification.\n"),
2313 if (buf_size < *ppos + append_size)
2315 memcpy (buf + *ppos, append, append_size);
2316 *ppos += append_size;
2331#define buffer_append_s(buf,ppos,buf_size,str) \
2332 buffer_append (buf,ppos,buf_size,str, MHD_STATICSTR_LEN_ (str))
2359 bool filter_transf_enc,
2360 bool filter_content_len,
2362 bool add_keep_alive)
2368 mhd_assert (! add_close || ! add_keep_alive);
2371 filter_transf_enc =
false;
2373 filter_content_len =
false;
2377 add_keep_alive =
false;
2384 size_t initial_pos = *ppos;
2387 if (filter_transf_enc)
2394 filter_transf_enc =
false;
2398 if (filter_content_len)
2414 if (buf_size < *ppos + el_size)
2418 buf[(*ppos)++] =
':';
2419 buf[(*ppos)++] =
' ';
2420 if (add_close || add_keep_alive)
2430 if (buf_size < initial_pos + el_size)
2432 memcpy (buf + *ppos,
"close, ",
2439 if (buf_size < initial_pos + el_size)
2441 memcpy (buf + *ppos,
"Keep-Alive, ",
2446 add_keep_alive =
false;
2451 buf[(*ppos)++] =
'\r';
2452 buf[(*ppos)++] =
'\n';
2453 mhd_assert (initial_pos + el_size == (*ppos));
2477 bool use_conn_close;
2478 bool use_conn_k_alive;
2489#ifdef UPGRADE_SUPPORT
2498#ifdef UPGRADE_SUPPORT
2510 use_conn_close =
true;
2511 use_conn_k_alive =
false;
2515 use_conn_close =
false;
2523 use_conn_k_alive =
true;
2525 use_conn_k_alive =
false;
2529 use_conn_close =
false;
2530 use_conn_k_alive =
false;
2569 if (buf_size < pos + 5)
2589 if (buf_size < pos + 2)
2603 if (buf_size < pos + 38)
2609 mhd_assert (! use_conn_close || ! use_conn_k_alive);
2610 mhd_assert (! use_conn_k_alive || ! use_conn_close);
2619 else if (use_conn_k_alive)
2670 if (buf_size < pos + 2)
2680 if (buf_size < pos + 2)
2722 buf[used_size++] =
'0';
2723 buf[used_size++] =
'\r';
2724 buf[used_size++] =
'\n';
2730 size_t new_used_size;
2733 if (new_used_size > buf_size)
2737 buf[used_size++] =
':';
2738 buf[used_size++] =
' ';
2741 buf[used_size++] =
'\r';
2742 buf[used_size++] =
'\n';
2746 if (used_size + 2 > buf_size)
2748 buf[used_size++] =
'\r';
2749 buf[used_size++] =
'\n';
2776 unsigned int status_code,
2777 const char *message,
2780 size_t header_name_len,
2782 size_t header_value_len)
2793 free (header_value);
2799 MHD_DLOG (connection->
daemon,
2800 _ (
"Error processing request (HTTP response code is %u ('%s')). " \
2801 "Closing connection.\n"),
2808 MHD_DLOG (connection->
daemon,
2809 _ (
"Too late to send an error response, " \
2810 "response is being sent already.\n"),
2815 _ (
"Too late for error response."));
2817 free (header_value);
2840 if (
NULL == response)
2843 MHD_DLOG (connection->
daemon,
2844 _ (
"Failed to create error response.\n"),
2851 free (header_value);
2860 if (
NULL != header_name)
2864 header_name, header_name_len,
2865 header_value, header_value_len);
2869 free (header_value);
2891 _ (
"Closing connection " \
2892 "(failed to queue error response)."));
2922 _ (
"Closing connection " \
2923 "(failed to create error response header)."));
2934#define transmit_error_response_static(c, code, msg) \
2935 transmit_error_response_len (c, code, \
2936 msg, MHD_STATICSTR_LEN_ (msg), \
2942#define transmit_error_response_header(c, code, m, hd_n, hd_n_l, hd_v, hd_v_l) \
2943 transmit_error_response_len (c, code, \
2944 m, MHD_STATICSTR_LEN_ (m), \
2996#ifndef MHD_MAX_REASONABLE_HEADERS_SIZE_
3006# define MHD_MAX_REASONABLE_HEADERS_SIZE_ (6 * 1024)
3009#ifndef MHD_MAX_REASONABLE_REQ_TARGET_SIZE_
3020# define MHD_MAX_REASONABLE_REQ_TARGET_SIZE_ 8000
3023#ifndef MHD_MIN_REASONABLE_HEADERS_SIZE_
3031# define MHD_MIN_REASONABLE_HEADERS_SIZE_ 26
3034#ifndef MHD_MIN_REASONABLE_REQ_TARGET_SIZE_
3042# define MHD_MIN_REASONABLE_REQ_TARGET_SIZE_ 40
3045#ifndef MHD_MIN_REASONABLE_REQ_METHOD_SIZE_
3053# define MHD_MIN_REASONABLE_REQ_METHOD_SIZE_ 16
3056#ifndef MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_
3062# define MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_ 4
3080 const char *add_element,
3081 size_t add_element_size)
3085 size_t opt_headers_size;
3086 size_t host_field_line_size;
3114 host_field_line_size = 0;
3119 && (0 != add_element_size))
3121 static const size_t header_host_key_len =
3123 const bool is_host_header =
3124 (header_host_key_len + 1 <= add_element_size)
3125 && ( (0 == add_element[header_host_key_len])
3126 || (
':' == add_element[header_host_key_len]) )
3129 header_host_key_len);
3132 const bool is_parsed = ! (
3136 size_t actual_element_size;
3138 mhd_assert (! is_parsed || (0 == add_element[header_host_key_len]));
3144 actual_element_size = add_element_size + 1;
3146 actual_element_size = add_element_size;
3148 host_field_line_size = actual_element_size;
3149 mhd_assert (opt_headers_size >= actual_element_size);
3150 opt_headers_size -= actual_element_size;
3153 if (0 == host_field_line_size)
3155 static const size_t host_field_name_len =
3157 size_t host_field_name_value_len;
3161 host_field_name_len,
3163 &host_field_name_value_len))
3167 host_field_line_size =
3168 host_field_name_len + host_field_name_value_len + 2;
3171 if (opt_headers_size >= host_field_line_size)
3173 opt_headers_size -= host_field_line_size;
3175 if (opt_headers_size >= 2)
3176 opt_headers_size -= 2;
3179 host_field_line_size = 0;
3189 method_size = strlen (c->
rq.
method);
3196 if (opt_headers_size > (uri_size / 8))
3198 if ((opt_headers_size / 2) > method_size)
3205 if ((uri_size / 16) > method_size)
3215 if ((uri_size / 16) > method_size)
3226 if ((opt_headers_size * 4) > uri_size)
3228 if (opt_headers_size > method_size)
3235 if (uri_size > method_size * 4)
3244 if (uri_size > method_size * 4)
3263 if ((1 < opt_headers_size) || (1 < uri_size))
3265 if (opt_headers_size >= uri_size)
3273 if (0 != host_field_line_size)
3292 const char *add_header,
3293 size_t add_header_size)
3295 unsigned int err_code;
3307#ifdef COOKIE_SUPPORT
3316 unsigned int err_code;
3343 const char *chunk_size_line,
3344 size_t chunk_size_line_size)
3346 unsigned int err_code;
3348 if (
NULL != chunk_size_line)
3350 const char *semicol;
3352 semicol = memchr (chunk_size_line,
';', chunk_size_line_size);
3353 if (
NULL != semicol)
3364 chunk_size_line_size);
3383 const char *add_footer,
3384 size_t add_footer_size)
3386 (void) add_footer; (void) add_footer_size;
3441 _ (
"No space left in the read buffer when " \
3442 "receiving the initial part of " \
3443 "the request line."));
3461 _ (
"No space left in the read buffer when " \
3462 "receiving the URI in " \
3463 "the request line. " \
3464 "The request uses non-standard HTTP request " \
3563 bool rbuff_grow_desired;
3567 bool rbuff_grow_required;
3573 if (rbuff_grow_required)
3574 rbuff_grow_desired =
true;
3580 if ((rbuff_grow_desired) &&
3588 rbuff_grow_desired =
3595 rbuff_grow_desired =
3600 const uint64_t cur_chunk_left =
3605 rbuff_grow_desired =
3612 if (! rbuff_grow_desired)
3618 if (! rbuff_grow_required)
3684#ifdef UPGRADE_SUPPORT
3685 case MHD_CONNECTION_UPGRADE:
3715 switch (connection->tls_state)
3722 if (0 == gnutls_record_get_direction (connection->tls_session))
3738 MHD_PANIC (
_ (
"Invalid TLS state value.\n"));
3745 MHD_DLOG (connection->
daemon,
3746 _ (
"In function %s handling connection at state: %s\n"),
3748 MHD_state_to_string (connection->
state));
3750 switch (connection->
state)
3842#ifdef UPGRADE_SUPPORT
3843 case MHD_CONNECTION_UPGRADE:
3895 MHD_DLOG (connection->
daemon,
3896 _ (
"Not enough memory in pool to allocate header record!\n"));
3907#ifdef COOKIE_SUPPORT
3912enum _MHD_ParseCookie
3914 MHD_PARSE_COOKIE_OK =
MHD_YES,
3915 MHD_PARSE_COOKIE_OK_LAX = 2,
3916 MHD_PARSE_COOKIE_MALFORMED = -1,
3917 MHD_PARSE_COOKIE_NO_MEMORY =
MHD_NO
3933static enum _MHD_ParseCookie
3934parse_cookies_string (
char *str,
3935 const size_t str_len,
3961 while (
' ' == str[i] ||
'\t' == str[i] ||
';' == str[i])
3963 if (! allow_wsp_empty)
3964 return MHD_PARSE_COOKIE_MALFORMED;
3968 return non_strict? MHD_PARSE_COOKIE_OK_LAX : MHD_PARSE_COOKIE_OK;
3975 const char l = str[i];
3976 if ((
'=' == l) || (
' ' == l) || (
'\t' == l) || (
'"' == l) || (
',' == l) ||
3977 (
';' == l) || (0 == l))
3979 }
while (str_len > ++i);
3980 name_len = i - name_start;
3982 while (str_len > i && (
' ' == str[i] ||
'\t' == str[i]))
3984 if (! wsp_around_eq)
3985 return MHD_PARSE_COOKIE_MALFORMED;
3989 if ((str_len == i) || (
'=' != str[i]) || (0 == name_len))
3990 return MHD_PARSE_COOKIE_MALFORMED;
3995 while (str_len > i && (
' ' == str[i] ||
'\t' == str[i]))
3997 if (! wsp_around_eq)
3998 return MHD_PARSE_COOKIE_MALFORMED;
4014 val_quoted = (
'"' == str[i]);
4021 const char l = str[i];
4022 if ((
';' == l) || (
'"' == l) || (
',' == l) || (
';' == l) ||
4023 (
'\\' == l) || (0 == l))
4025 if ((
' ' == l) || (
'\t' == l))
4029 if (! wsp_in_quoted)
4030 return MHD_PARSE_COOKIE_MALFORMED;
4035 value_len = i - value_start;
4038 if ((str_len == i) || (
'"' != str[i]))
4039 return MHD_PARSE_COOKIE_MALFORMED;
4043 if ((str_len > i) && ((
' ' == str[i]) || (
'\t' == str[i])))
4048 }
while (str_len > i && (
' ' == str[i] ||
'\t' == str[i]));
4052 if (! allow_wsp_empty)
4053 return MHD_PARSE_COOKIE_MALFORMED;
4058 valid_cookie =
true;
4059 else if (
';' == str[i])
4060 valid_cookie =
true;
4062 valid_cookie =
false;
4065 return MHD_PARSE_COOKIE_MALFORMED;
4068 str[name_start + name_len] = 0;
4071 mhd_assert (value_start + value_len <= str_len);
4072 str[value_start + value_len] = 0;
4080 return MHD_PARSE_COOKIE_NO_MEMORY;
4091 return MHD_PARSE_COOKIE_NO_MEMORY;
4097 mhd_assert (
';' != str[i] || val_quoted || non_strict || 0 == value_len);
4101 if (! allow_wsp_empty)
4102 return MHD_PARSE_COOKIE_MALFORMED;
4105 else if (
' ' != str[i])
4107 if ((
'\t' == str[i]) && tab_as_sp)
4109 else if (! allow_no_space)
4110 return MHD_PARSE_COOKIE_MALFORMED;
4118 if (! allow_wsp_empty)
4119 return MHD_PARSE_COOKIE_MALFORMED;
4125 return non_strict? MHD_PARSE_COOKIE_OK_LAX : MHD_PARSE_COOKIE_OK;
4135static enum _MHD_ParseCookie
4142 enum _MHD_ParseCookie parse_res;
4145 const bool allow_partially_correct_cookie =
4156 return MHD_PARSE_COOKIE_OK;
4158 return MHD_PARSE_COOKIE_OK;
4163 parse_res = MHD_PARSE_COOKIE_NO_MEMORY;
4169 cpy[hdr_len] =
'\0';
4173 while (i < hdr_len && (
' ' == cpy[i] ||
'\t' == cpy[i]))
4176 parse_res = parse_cookies_string (cpy + i, hdr_len - i, connection);
4181 case MHD_PARSE_COOKIE_OK:
4183 case MHD_PARSE_COOKIE_OK_LAX:
4186 MHD_DLOG (connection->
daemon,
4187 _ (
"The Cookie header has been parsed, but it is not fully "
4188 "compliant with the standard.\n"));
4191 case MHD_PARSE_COOKIE_MALFORMED:
4194 if (! allow_partially_correct_cookie)
4201 MHD_DLOG (connection->
daemon,
4202 _ (
"The Cookie header has been ignored as it contains "
4203 "malformed data.\n"));
4208 MHD_DLOG (connection->
daemon,
4209 _ (
"The Cookie header has been only partially parsed as it "
4210 "contains malformed data.\n"));
4215 MHD_DLOG (connection->
daemon,
4216 _ (
"The Cookie header has malformed data.\n"));
4219 case MHD_PARSE_COOKIE_NO_MEMORY:
4221 MHD_DLOG (connection->
daemon,
4222 _ (
"Not enough memory in the connection pool to "
4223 "parse client cookies!\n"));
4230#ifndef HAVE_MESSAGES
4244#define HTTP_VER_LEN (MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1))
4257 const char *http_string,
4260 const char *
const h = http_string;
4266 (
'H' != h[0]) || (
'T' != h[1]) || (
'T' != h[2]) || (
'P' != h[3]) ||
4269 ((
'0' > h[5]) || (
'9' < h[5])) ||
4270 ((
'0' > h[7]) || (
'9' < h[7])))
4278 if (1 == h[5] -
'0')
4281 if (1 == h[7] -
'0')
4283 else if (0 == h[7] -
'0')
4291 if (0 == h[5] -
'0')
4321 const char *
const m = method;
4385 _ (
"Application reported internal error, " \
4386 "closing connection."));
4415 const bool allow_bws = (2 < discp_lvl);
4423 size_t to_be_processed;
4424 size_t left_unprocessed;
4425 size_t processed_size;
4427 instant_retry =
false;
4439 if ( (2 <= available) &&
4440 (
'\r' == buffer_head[0]) &&
4441 (
'\n' == buffer_head[1]) )
4443 else if (bare_lf_as_crlf && (
'\n' == buffer_head[0]))
4445 else if (2 > available)
4464 uint64_t cur_chunk_left;
4473 if (cur_chunk_left > available)
4474 to_be_processed = available;
4477 to_be_processed = (size_t) cur_chunk_left;
4478 if (available > to_be_processed)
4479 instant_retry =
true;
4486 uint64_t chunk_size;
4500 if (num_dig == available)
4503 broken = (0 == num_dig);
4506 overflow = (((
'0' <= buffer_head[0]) && (
'9' >= buffer_head[0])) ||
4507 ((
'A' <= buffer_head[0]) && (
'F' >= buffer_head[0])) ||
4508 ((
'a' <= buffer_head[0]) && (
'f' >= buffer_head[0])));
4515 size_t chunk_size_line_len;
4517 chunk_size_line_len = 0;
4518 if ((
';' == buffer_head[num_dig]) ||
4520 ((
' ' == buffer_head[num_dig]) ||
4521 (
'\t' == buffer_head[num_dig]))))
4526 for (i = num_dig; i < available; ++i)
4528 if ((
' ' != buffer_head[i]) && (
'\t' != buffer_head[i]))
4533 if (
';' == buffer_head[i])
4535 for (++i; i < available; ++i)
4537 if (
'\n' == buffer_head[i])
4545 if (bare_lf_as_crlf)
4546 chunk_size_line_len = i;
4547 else if (
'\r' == buffer_head[i - 1])
4548 chunk_size_line_len = i;
4559 if ((2 <= (available - num_dig)) &&
4560 (
'\r' == buffer_head[num_dig]) &&
4561 (
'\n' == buffer_head[num_dig + 1]))
4562 chunk_size_line_len = num_dig + 2;
4563 else if (bare_lf_as_crlf &&
4564 (
'\n' == buffer_head[num_dig]))
4565 chunk_size_line_len = num_dig + 1;
4566 else if (2 > (available - num_dig))
4570 if (0 != chunk_size_line_len)
4572 mhd_assert (chunk_size_line_len <= available);
4577 available -= chunk_size_line_len;
4578 buffer_head += chunk_size_line_len;
4580 if (0 == chunk_size)
4586 instant_retry =
true;
4611 to_be_processed = available;
4613 left_unprocessed = to_be_processed;
4629 _ (
"Application reported internal error, " \
4630 "closing connection."));
4635 if (left_unprocessed > to_be_processed)
4636 MHD_PANIC (
_ (
"libmicrohttpd API violation.\n"));
4639 (left_unprocessed != to_be_processed);
4641 if (0 != left_unprocessed)
4643 instant_retry =
false;
4653 _ (
"WARNING: Access Handler Callback has not processed " \
4654 "any upload data and connection is not suspended. " \
4655 "This may result in hung connection.\n"));
4659 processed_size = to_be_processed - left_unprocessed;
4661 buffer_head += processed_size;
4662 available -= processed_size;
4673 }
while (instant_retry);
4675 if ( (available > 0) &&
4706 connection->
state = next_state;
4725#ifdef COOKIE_SUPPORT
4728 handle_req_cookie_no_space (connection);
4744 MHD_DLOG (connection->
daemon,
4745 _ (
"Received HTTP/1.1 request without `Host' header.\n"));
4797 MHD_DLOG (connection->
daemon,
4798 _ (
"The 'Content-Length' request header is ignored "
4799 "as chunked Transfer-Encoding is used "
4800 "for this request.\n"));
4822 if (((0 == num_digits) &&
4824 (
'0' <= clen[0]) && (
'9' >= clen[0]))
4829 MHD_DLOG (connection->
daemon,
4830 _ (
"Too large value of 'Content-Length' header. " \
4831 "Closing connection.\n"));
4837 else if ((val_len != num_digits) ||
4842 MHD_DLOG (connection->
daemon,
4843 _ (
"Failed to parse 'Content-Length' header. " \
4844 "Closing connection.\n"));
4861_MHD_static_inline
void
4872_MHD_static_inline
void
4881#ifndef MHD_MAX_EMPTY_LINES_SKIP
4886#define MHD_MAX_EMPTY_LINES_SKIP 1024
4903 const bool skip_empty_lines = (1 >= discp_lvl);
4906 const bool skip_several_empty_lines = (skip_empty_lines && (0 >= discp_lvl));
4909 const bool skip_unlimited_empty_lines =
4910 (skip_empty_lines && (-3 >= discp_lvl));
4916 const bool tab_as_wsp = (0 >= discp_lvl);
4919 const bool other_wsp_as_wsp = (-1 >= discp_lvl);
4922 const bool wsp_blocks = (-1 >= discp_lvl);
4925 const bool wsp_in_uri = (0 >= discp_lvl);
4929 const bool wsp_in_uri_keep = (-2 >= discp_lvl);
4932 const bool bare_cr_keep = (wsp_in_uri_keep && (-3 >= discp_lvl));
4935 const bool bare_cr_as_sp = ((! bare_cr_keep) && (-1 >= discp_lvl));
4957 && (skip_empty_lines))
4971 is_empty_line =
false;
4978 is_empty_line =
true;
4988 is_empty_line =
true;
4996 if ((! skip_unlimited_empty_lines) &&
4997 (((
unsigned int) ((skip_several_empty_lines) ?
5002 _ (
"Too many meaningless extra empty lines " \
5003 "received before the request"));
5009 }
while (is_empty_line);
5017 while (p < c->read_buffer_offset)
5036 end_of_line =
false;
5065 else if (! bare_cr_keep)
5077 _ (
"Bare CR characters are not allowed " \
5078 "in the request line.\n"));
5083 else if (
'\n' == chr)
5087 if (bare_lf_as_crlf)
5104 _ (
"Bare LF characters are not allowed " \
5105 "in the request line.\n"));
5229 _ (
"The request line is malformed.\n"));
5235 if ((! wsp_blocks) &&
5272 || ((
'\t' == chr) && (tab_as_wsp))
5273 || ((other_wsp_as_wsp) && ((0xb == chr) || (0xc == chr))))
5292 _ (
"The request line starts with "
5293 "a whitespace.\n"));
5330 _ (
"The request line has more than "
5331 "two whitespaces.\n"));
5406 else if ((0xb == chr) || (0xc == chr))
5419 _ (
"Invalid character is in the "
5420 "request line.\n"));
5428 _ (
"The NUL character is in the "
5429 "request line.\n"));
5442#ifndef MHD_MAX_FIXED_URI_LEN
5446#define MHD_MAX_FIXED_URI_LEN (64 * 1024)
5460 size_t fixed_uri_len;
5464 size_t hdr_name_len;
5474 (
NULL == (b = malloc (fixed_uri_len + 1))) )
5477 _ (
"The request has whitespace character is " \
5478 "in the URI and the URI is too large to " \
5479 "send automatic redirect to fixed URI.\n"));
5518 }
while (i < c->rq.req_target_len);
5523 hdr_name = malloc (hdr_name_len + 1);
5524 if (
NULL != hdr_name)
5541 _ (
"The request has whitespace character is in the " \
5629 const bool wsp_in_uri = (0 >= discp_lvl);
5632 const bool wsp_in_uri_keep = (-2 >= discp_lvl);
5667 if (! wsp_in_uri_keep)
5718 bool process_footers,
5730 const bool bare_cr_keep = (-3 >= discp_lvl);
5733 const bool bare_cr_as_sp = ((! bare_cr_keep) && (-1 >= discp_lvl));
5736 const bool nul_as_sp = (-1 >= discp_lvl);
5739 const bool allow_folded = (0 >= discp_lvl);
5745 const bool allow_wsp_at_start = allow_folded && (-1 >= discp_lvl);
5748 const bool allow_wsp_in_name = (-2 >= discp_lvl);
5751 const bool allow_empty_name = (-2 >= discp_lvl);
5754 const bool allow_wsp_before_colon = (-3 >= discp_lvl);
5758 const bool allow_line_without_colon = (-2 >= discp_lvl);
5762#if ! defined (HAVE_MESSAGES) && ! defined(_DEBUG)
5763 (void) process_footers;
5773 while (p < c->read_buffer_offset)
5822 else if (! bare_cr_keep)
5824 if (! process_footers)
5834 end_of_line =
false;
5837 else if (
'\n' == chr)
5841 if (bare_lf_as_crlf)
5853 if (! process_footers)
5865 end_of_line =
false;
5873 const size_t line_len = p + ((
'\r' == chr) ? 2 : 1);
5874 char next_line_char;
5875 mhd_assert (line_len <= c->read_buffer_offset);
5894 mhd_assert (line_len < c->read_buffer_offset);
5898 if ((
' ' == next_line_char) ||
5899 (
'\t' == next_line_char))
5904 if (! process_footers)
5925 bool skip_line =
false;
5935 _ (
"Whitespace-prefixed first header line " \
5936 "has been skipped.\n"));
5942 if (! allow_line_without_colon)
5944 if (! process_footers)
6001 hdr_value->
len = value_len;
6011 else if ((
' ' == chr) || (
'\t' == chr))
6015 if (! allow_wsp_at_start)
6017 if (! process_footers)
6033 if (allow_wsp_in_name || allow_wsp_before_colon)
6040 if (! process_footers)
6063 if (! process_footers)
6093 mhd_assert (allow_wsp_in_name || allow_wsp_before_colon);
6094 if (! allow_wsp_before_colon)
6096 if (! process_footers)
6107#ifndef MHD_FAVOR_SMALL_CODE
6113 if (! process_footers)
6131 mhd_assert (allow_wsp_in_name || allow_wsp_before_colon);
6132 if (! allow_wsp_in_name)
6134 if (! process_footers)
6145#ifndef MHD_FAVOR_SMALL_CODE
6156#ifndef MHD_FAVOR_SMALL_CODE
6160#ifdef MHD_FAVOR_SMALL_CODE
6198 res =
get_req_header (c, process_footers, &hdr_name, &hdr_value);
6213 (hdr_name.
str[hdr_name.
len - 1] !=
' '));
6215 (hdr_name.
str[hdr_name.
len - 1] !=
'\t'));
6219 (hdr_value.
str[hdr_value.
len - 1] !=
' '));
6221 (hdr_value.
str[hdr_value.
len - 1] !=
'\t'));
6225 (! process_footers) ?
6228 hdr_name.
str, hdr_name.
len,
6229 hdr_value.
str, hdr_value.
len))
6231 size_t add_element_size;
6237 _ (
"Failed to allocate memory in the connection memory " \
6238 "pool to store %s.\n"),
6239 (! process_footers) ?
_ (
"header") :
_ (
"footer"));
6242 add_element_size = hdr_value.
len
6243 + (size_t) (hdr_value.
str - hdr_name.
str);
6245 if (! process_footers)
6285 _ (
"One bare CR character has been replaced with space " \
6287 (! process_footers) ?
6288 _ (
"the request line or in the request headers") :
6289 _ (
"the request footers"));
6294 _ (
"%" PRIu64 " bare CR characters have been replaced with " \
6295 "spaces in the request line and/or in the request %s.\n"),
6297 (! process_footers) ?
_ (
"headers") :
_ (
"footers"));
6302 _ (
"One %s line without colon has been skipped.\n"),
6303 (! process_footers) ?
_ (
"header") :
_ (
"footer"));
6308 _ (
"%" PRIu64 " %s lines without colons has been skipped.\n"),
6310 (! process_footers) ?
_ (
"header") :
_ (
"footer"));
6315 if (! process_footers)
6334 const char *last_elmnt_end;
6335 size_t shift_back_size;
6343 shift_back_size = (size_t) (c->
read_buffer - (last_elmnt_end + 1));
6370#if defined(MHD_USE_THREADS)
6386#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6396#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6435 bytes_read = connection->
recv_cls (connection,
6440 if ((bytes_read < 0) || socket_error)
6444 if ((bytes_read > 0) && connection->
sk_nonblck)
6447 bytes_read = connection->
recv_cls (connection, &dummy,
sizeof (dummy));
6455 MHD_DLOG (connection->
daemon,
6456 _ (
"Socket has been disconnected when reading request.\n"));
6467 MHD_DLOG (connection->
daemon,
6468 _ (
"Connection socket is closed when reading " \
6469 "request due to the error: %s\n"),
6470 (bytes_read < 0) ? str_conn_error_ (bytes_read) :
6471 "detected connection closure");
6478 if (0 == bytes_read)
6485 MHD_DLOG (connection->
daemon,
6486 _ (
"Connection was closed by remote side with incomplete "
6506 MHD_DLOG (connection->
daemon,
6507 _ (
"In function %s handling connection at state: %s\n"),
6509 MHD_state_to_string (connection->
state));
6512 switch (connection->
state)
6530#ifdef UPGRADE_SUPPORT
6531 case MHD_CONNECTION_UPGRADE:
6604 MHD_DLOG (connection->
daemon,
6605 _ (
"In function %s handling connection at state: %s\n"),
6607 MHD_state_to_string (connection->
state));
6609 switch (connection->
state)
6631 MHD_DLOG (connection->
daemon,
6632 _ (
"Failed to send data in request for %s.\n"),
6633 connection->
rq.
url);
6639#if _MHD_DEBUG_SEND_DATA
6641 _ (
"Sent 100 continue response: `%.*s'\n"),
6717 MHD_DLOG (connection->
daemon,
6718 _ (
"Failed to send the response headers for the " \
6719 "request for `%s'. Error: %s\n"),
6721 str_conn_error_ (ret));
6728 if (((
size_t) ret) > wb_ready)
6754 uint64_t data_write_offset;
6756#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6765#if defined(_MHD_HAVE_SENDFILE)
6766 if (MHD_resp_sender_sendfile == connection->
rp.resp_sender)
6769 ret = MHD_send_sendfile_ (connection);
6783 if (data_write_offset > (uint64_t)
SIZE_MAX)
6784 MHD_PANIC (
_ (
"Data offset exceeds limit.\n"));
6787 [(
size_t) data_write_offset],
6789 - (
size_t) data_write_offset,
6791#if _MHD_DEBUG_SEND_DATA
6794 _ (
"Sent %d-byte DATA response: `%.*s'\n"),
6798 - rp.response->data_start]);
6801#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6810 MHD_DLOG (connection->
daemon,
6811 _ (
"Failed to send the response body for the " \
6812 "request for `%s'. Error: %s\n"),
6814 str_conn_error_ (ret));
6842 MHD_DLOG (connection->
daemon,
6843 _ (
"Failed to send the chunked response body for the " \
6844 "request for `%s'. Error: %s\n"),
6846 str_conn_error_ (ret));
6878 MHD_DLOG (connection->
daemon,
6879 _ (
"Failed to send the footers for the " \
6880 "request for `%s'. Error: %s\n"),
6882 str_conn_error_ (ret));
6900#ifdef UPGRADE_SUPPORT
6901 case MHD_CONNECTION_UPGRADE:
6908 _ (
"Internal error.\n"));
6926 uint64_t since_actv;
6936 if (timeout < since_actv)
6943 if (5000 >= jump_back)
6947 _ (
"Detected system clock %u milliseconds jump back.\n"),
6948 (
unsigned int) jump_back);
6954 _ (
"Detected too large system clock %" PRIu64 " milliseconds "
6977#ifdef MHD_USE_THREADS
6991#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7023#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7031 if ( (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
7032 (! MHD_itc_activate_ (daemon->
itc,
"c")) )
7036 _ (
"Failed to signal end of connection via inter-thread " \
7037 "communication channel.\n"));
7052 size_t read_buf_size;
7065 memset (&c->
rq, 0,
sizeof(c->
rq));
7066 memset (&c->
rp, 0,
sizeof(c->
rp));
7117 size_t new_read_buf_size;
7139 memset (&c->
rq, 0,
sizeof(c->
rq));
7142 memset (&c->
rp, 0,
sizeof(c->
rp));
7184#ifdef MHD_USE_THREADS
7204 _ (
"In function %s handling connection at state: %s\n"),
7206 MHD_state_to_string (connection->
state));
7208 switch (connection->
state)
7350 _ (
"Closing connection (failed to create "
7351 "response header).\n"));
7361#ifdef UPGRADE_SUPPORT
7364 connection->
state = MHD_CONNECTION_UPGRADE;
7405#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7411#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7423#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7443#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7451#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7463#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7484 _ (
"Closing connection (failed to create " \
7485 "response footer)."));
7517#ifdef UPGRADE_SUPPORT
7518 case MHD_CONNECTION_UPGRADE:
7541 ret = MHD_connection_epoll_update_ (connection);
7570 daemon->eready_tail,
7583 struct epoll_event event;
7585 event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET;
7586 event.data.ptr = connection;
7587 if (0 != epoll_ctl (daemon->epoll_fd,
7595 _ (
"Call to epoll_ctl failed: %s\n"),
7644 if (
NULL == connection->tls_session)
7648 gnutls_cipher_algorithm_t res;
7649 res = gnutls_cipher_get (connection->tls_session);
7654 if (
NULL == connection->tls_session)
7658 gnutls_protocol_t res;
7659 res = gnutls_protocol_get_version (connection->tls_session);
7664 if (
NULL == connection->tls_session)
7682 sizeof(connection->
addr));
7702#if SIZEOF_UNSIGNED_INT <= (SIZEOF_UINT64_T - 2)
7743 unsigned int ui_val;
7745 daemon = connection->
daemon;
7751 va_start (ap, option);
7752 ui_val = va_arg (ap,
unsigned int);
7754#if (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT
7758 MHD_DLOG (connection->
daemon,
7759 _ (
"The specified connection timeout (%u) is too " \
7760 "large. Maximum allowed value (%" PRIu64 ") will be used " \
7770#if defined(MHD_USE_THREADS)
7793#if defined(MHD_USE_THREADS)
7851 unsigned int status_code,
7857 if ((
NULL == connection) || (
NULL == response))
7860 daemon = connection->
daemon;
7868#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7875 _ (
"Attempted to queue response on wrong thread!\n"));
7891#ifdef UPGRADE_SUPPORT
7892 if (
NULL != response->upgrade_handler)
7899 _ (
"Attempted 'upgrade' connection on daemon without" \
7900 " MHD_ALLOW_UPGRADE option!\n"));
7908 _ (
"Application used invalid status code for" \
7909 " 'upgrade' response!\n"));
7917 _ (
"Application used invalid response" \
7918 " without \"Connection\" header!\n"));
7931 _ (
"Application used invalid response" \
7932 " without \"upgrade\" token in" \
7933 " \"Connection\" header!\n"));
7941 _ (
"Connection \"Upgrade\" can be used only " \
7942 "with HTTP/1.1 connections!\n"));
7950#ifdef UPGRADE_SUPPORT
7951 if (
NULL == response->upgrade_handler)
7955 _ (
"Application used status code 101 \"Switching Protocols\" " \
7956 "with non-'upgrade' response!\n"));
7963 _ (
"Application used status code 101 \"Switching Protocols\", " \
7964 "but this MHD was built without \"Upgrade\" support!\n"));
7969 if ( (100 > status_code) ||
7970 (999 < status_code) )
7974 _ (
"Refused wrong status code (%u). " \
7975 "HTTP requires three digits status code!\n"),
7980 if (200 > status_code)
7986 _ (
"Wrong status code (%u) refused. " \
7987 "HTTP/1.0 clients do not support 1xx status codes!\n"),
7997 _ (
"Wrong status code (%u) refused. " \
7998 "HTTP/1.0 reply mode does not support 1xx status codes!\n"),
8005 (2 == status_code / 100) )
8009 _ (
"Successful (%u) response code cannot be used to answer " \
8010 "\"CONNECT\" request!\n"),
8021 _ (
"HEAD-only response cannot be used when the request requires "
8022 "reply body to be sent!\n"));
8032 _ (
"The response has application-defined \"Content-Length\" " \
8033 "header. The reply to the request will be not " \
8034 "HTTP-compliant and may result in hung connection or " \
8035 "other problems!\n"));
8043#if defined(_MHD_HAVE_SENDFILE)
8044 if ( (response->
fd == -1) ||
8048 defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE)
8053 connection->
rp.resp_sender = MHD_resp_sender_std;
8055 connection->
rp.resp_sender = MHD_resp_sender_sendfile;
#define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG
#define REQUEST_CONTENTLENGTH_TOOLARGE
static enum MHD_Result build_connection_chunked_response_footer(struct MHD_Connection *connection)
static ssize_t recv_param_adapter(struct MHD_Connection *connection, void *other, size_t i)
#define ERR_RSP_EMPTY_FOOTER_NAME
static enum MHD_Result build_header_response(struct MHD_Connection *connection)
static void connection_close_error(struct MHD_Connection *connection, const char *emsg)
static bool process_request_target(struct MHD_Connection *c)
void MHD_connection_set_initial_state_(struct MHD_Connection *c)
#define MHD_CHUNK_HEADER_REASONABLE_LEN
@ MHD_PROC_RECV_BODY_CHUNKED
@ MHD_PROC_RECV_BODY_NORMAL
#define REQUEST_CHUNK_TOO_LARGE
void MHD_connection_handle_write(struct MHD_Connection *connection)
static void MHD_connection_update_event_loop_info(struct MHD_Connection *connection)
#define buffer_append_s(buf, ppos, buf_size, str)
void * MHD_connection_alloc_memory_(struct MHD_Connection *connection, size_t size)
#define MHD_MAX_FIXED_URI_LEN
static enum MHD_Result try_ready_normal_body(struct MHD_Connection *connection)
#define REQUEST_CHUNKED_MALFORMED
#define REQ_HTTP_VER_IS_NOT_SUPPORTED
#define MHD_MAX_REASONABLE_HEADERS_SIZE_
#define RQ_LINE_TOO_MANY_WSP
static void call_connection_handler(struct MHD_Connection *connection)
static enum MHD_Result connection_add_header(void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind)
static void process_request_body(struct MHD_Connection *connection)
#define ERR_RSP_INVALID_CHR_IN_FOOTER
static void setup_reply_properties(struct MHD_Connection *connection)
static void send_redirect_fixed_rq_target(struct MHD_Connection *c)
static void handle_recv_no_space(struct MHD_Connection *c, enum MHD_ProcRecvDataStage stage)
#define transmit_error_response_static(c, code, msg)
static bool get_request_line(struct MHD_Connection *c)
@ MHD_HDR_LINE_READING_NEED_MORE_DATA
@ MHD_HDR_LINE_READING_GOT_END_OF_HEADER
@ MHD_HDR_LINE_READING_GOT_HEADER
@ MHD_HDR_LINE_READING_DATA_ERROR
_MHD_static_inline void reset_rq_header_processing_state(struct MHD_Connection *c)
#define ERR_RSP_HEADER_WITHOUT_COLON
static void connection_shrink_read_buffer(struct MHD_Connection *connection)
#define ERR_RSP_WSP_IN_FOOTER_NAME
#define MHD_ALLOW_BARE_LF_AS_CRLF_(discp_lvl)
static enum replyBodyUse is_reply_body_needed(struct MHD_Connection *connection, unsigned int rcode)
void MHD_set_http_callbacks_(struct MHD_Connection *connection)
static void transmit_error_response_len(struct MHD_Connection *connection, unsigned int status_code, const char *message, size_t message_len, char *header_name, size_t header_name_len, char *header_value, size_t header_value_len)
#define REQ_HTTP_VER_IS_TOO_OLD
#define ERR_MSG_REQUEST_TOO_BIG
#define MHD_MAX_REASONABLE_REQ_TARGET_SIZE_
#define ERR_MSG_REQUEST_FOOTER_TOO_BIG
#define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG
static bool connection_check_timedout(struct MHD_Connection *c)
static enum MHD_ConnKeepAlive keepalive_possible(struct MHD_Connection *connection)
static void handle_req_chunk_size_line_no_space(struct MHD_Connection *c, const char *chunk_size_line, size_t chunk_size_line_size)
#define BARE_CR_IN_FOOTER
static bool try_grow_read_buffer(struct MHD_Connection *connection, bool required)
static bool parse_http_version(struct MHD_Connection *connection, const char *http_string, size_t len)
#define BARE_LF_IN_HEADER
#define ERR_RSP_EMPTY_HEADER_NAME
static bool need_100_continue(struct MHD_Connection *connection)
#define ERR_RSP_WSP_IN_HEADER_NAME
static bool get_req_headers(struct MHD_Connection *c, bool process_footers)
#define ERROR_MSG_DATA_NOT_HANDLED_BY_APP
#define MHD_MIN_REASONABLE_REQ_METHOD_SIZE_
static unsigned int get_no_space_err_status_code(struct MHD_Connection *c, enum MHD_ProcRecvDataStage stage, const char *add_element, size_t add_element_size)
#define REQUEST_UNSUPPORTED_TR_ENCODING
enum MHD_Result MHD_connection_handle_idle(struct MHD_Connection *connection)
static void cleanup_connection(struct MHD_Connection *connection)
#define ERR_RSP_OBS_FOLD_FOOTER
static void parse_http_std_method(struct MHD_Connection *connection, const char *method, size_t len)
static bool check_and_grow_read_buffer_space(struct MHD_Connection *c)
static enum MHD_Result try_ready_chunked_body(struct MHD_Connection *connection, bool *p_finished)
static bool get_date_str(char *date)
#define BARE_LF_IN_FOOTER
static void connection_reset(struct MHD_Connection *connection, bool reuse)
#define REQUEST_LENGTH_WITH_TR_ENCODING
#define MHD_MIN_REASONABLE_REQ_TARGET_SIZE_
#define RQ_TARGET_INVALID_CHAR
static bool get_request_line_inner(struct MHD_Connection *c)
static void handle_req_footers_no_space(struct MHD_Connection *c, const char *add_footer, size_t add_footer_size)
void MHD_connection_handle_read(struct MHD_Connection *connection, bool socket_error)
static void connection_switch_from_recv_to_send(struct MHD_Connection *connection)
#define ERR_RSP_WSP_BEFORE_FOOTER
static void parse_connection_headers(struct MHD_Connection *connection)
#define ERR_RSP_INVALID_CHR_IN_HEADER
void MHD_update_last_activity_(struct MHD_Connection *connection)
#define MHD_MAX_EMPTY_LINES_SKIP
#define MHD_MIN_REASONABLE_HEADERS_SIZE_
#define BARE_CR_IN_HEADER
#define ERR_MSG_REQUEST_HEADER_TOO_BIG
static bool add_user_headers(char *buf, size_t *ppos, size_t buf_size, struct MHD_Response *response, bool filter_transf_enc, bool filter_content_len, bool add_close, bool add_keep_alive)
#define REQUEST_CONTENTLENGTH_MALFORMED
static enum MHD_HdrLineReadRes_ get_req_header(struct MHD_Connection *c, bool process_footers, struct _MHD_str_w_len *hdr_name, struct _MHD_str_w_len *hdr_value)
static void check_connection_reply(struct MHD_Connection *connection)
static void handle_req_headers_no_space(struct MHD_Connection *c, const char *add_header, size_t add_header_size)
void MHD_connection_close_(struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code)
static size_t connection_maximize_write_buffer(struct MHD_Connection *connection)
static bool has_unprocessed_upload_body_data_in_buffer(struct MHD_Connection *c)
void MHD_connection_mark_closed_(struct MHD_Connection *connection)
#define CONNECTION_CLOSE_ERROR(c, emsg)
#define transmit_error_response_header(c, code, m, hd_n, hd_n_l, hd_v, hd_v_l)
static bool buffer_append(char *buf, size_t *ppos, size_t buf_size, const char *append, size_t append_size)
static enum MHD_Result check_write_done(struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state)
#define ERR_RSP_WSP_BEFORE_HEADER
#define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG
_MHD_static_inline void switch_to_rq_headers_processing(struct MHD_Connection *c)
static bool get_date_header(char *header)
static bool MHD_lookup_header_token_ci(const struct MHD_Connection *connection, const char *header, size_t header_len, const char *token, size_t token_len)
#define ERR_RSP_FOOTER_WITHOUT_COLON
#define MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_
Methods for managing connections.
#define MHD_connection_finish_forward_(conn)
#define MHD_ERR_OPNOTSUPP_
static ssize_t recv_param_adapter(struct MHD_Connection *connection, void *other, size_t i)
static bool need_100_continue(struct MHD_Request *request)
#define HTTP_100_CONTINUE
#define REQUEST_MALFORMED
static bool try_ready_chunked_body(struct MHD_Request *request)
#define MHD_lookup_header_s_token_ci(r, h, tkn)
#define REQUEST_LACKS_HOST
static bool try_ready_normal_body(struct MHD_Request *request)
static bool build_header_response(struct MHD_Request *request)
static bool try_grow_read_buffer(struct MHD_Request *request)
static int parse_cookie_header(struct MHD_Request *request)
bool MHD_tls_connection_shutdown(struct MHD_Connection *connection)
bool MHD_run_tls_handshake_(struct MHD_Connection *connection)
Methods for managing connections.
#define MHD_HTTP_INTERNAL_SERVER_ERROR
#define MHD_HTTP_MOVED_PERMANENTLY
#define MHD_HTTP_URI_TOO_LONG
#define MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
#define MHD_HTTP_PROCESSING
#define MHD_HTTP_NOT_IMPLEMENTED
#define MHD_HTTP_SWITCHING_PROTOCOLS
#define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED
#define MHD_HTTP_CONTENT_TOO_LARGE
#define MHD_HTTP_NOT_MODIFIED
#define MHD_HTTP_NO_CONTENT
#define MHD_HTTP_BAD_REQUEST
#define MHD_HTTP_METHOD_TRACE
#define MHD_HTTP_METHOD_OPTIONS
#define MHD_HTTP_METHOD_GET
#define MHD_HTTP_METHOD_HEAD
#define MHD_HTTP_METHOD_POST
#define MHD_HTTP_METHOD_PUT
#define MHD_HTTP_METHOD_CONNECT
#define MHD_HTTP_METHOD_DELETE
_MHD_EXTERN enum MHD_Result MHD_set_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value)
enum MHD_Result(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
enum MHD_Result(* MHD_KeyValueIteratorN)(void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size)
_MHD_EXTERN int MHD_get_connection_values_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls)
_MHD_EXTERN int MHD_get_connection_values(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
static enum MHD_Result MHD_set_connection_value_n_nocheck_(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size)
_MHD_EXTERN enum MHD_Result MHD_set_connection_value_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size)
_MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr)
MHD_RequestTerminationCode
@ MHD_CONNECTION_INFO_CONNECTION_TIMEOUT
@ MHD_CONNECTION_INFO_SOCKET_CONTEXT
@ MHD_CONNECTION_INFO_GNUTLS_SESSION
@ MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE
@ MHD_CONNECTION_INFO_CIPHER_ALGO
@ MHD_CONNECTION_INFO_CONNECTION_SUSPENDED
@ MHD_CONNECTION_INFO_CLIENT_ADDRESS
@ MHD_CONNECTION_INFO_DAEMON
@ MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT
@ MHD_CONNECTION_INFO_HTTP_STATUS
@ MHD_CONNECTION_INFO_CONNECTION_FD
@ MHD_CONNECTION_INFO_PROTOCOL
@ MHD_REQUEST_TERMINATED_TIMEOUT_REACHED
@ MHD_REQUEST_TERMINATED_COMPLETED_OK
@ MHD_REQUEST_TERMINATED_WITH_ERROR
@ MHD_REQUEST_TERMINATED_READ_ERROR
@ MHD_REQUEST_TERMINATED_CLIENT_ABORT
_MHD_EXTERN enum MHD_Result MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_static(size_t size, const void *buffer)
_MHD_EXTERN enum MHD_Result MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
_MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
#define MHD_HTTP_VERSION_1_0
#define MHD_HTTP_VERSION_1_1
bool MHD_parse_arguments_(struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
#define MHD_ERR_CONNRESET_
#define XDLL_insert(head, tail, element)
@ MHD_EPOLL_STATE_SUSPENDED
@ MHD_EPOLL_STATE_IN_EREADY_EDLL
@ MHD_EPOLL_STATE_READ_READY
@ MHD_EPOLL_STATE_IN_EPOLL_SET
@ MHD_EPOLL_STATE_WRITE_READY
#define DLL_insert(head, tail, element)
#define EDLL_insert(head, tail, element)
@ MHD_CONN_KEEPALIVE_UNKOWN
#define EDLL_remove(head, tail, element)
#define XDLL_remove(head, tail, element)
#define DLL_remove(head, tail, element)
void * MHD_pool_reallocate(struct MemoryPool *pool, void *old, size_t old_size, size_t new_size)
void MHD_pool_destroy(struct MemoryPool *pool)
size_t MHD_pool_get_free(struct MemoryPool *pool)
void * MHD_pool_reset(struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size)
void * MHD_pool_allocate(struct MemoryPool *pool, size_t size, int from_end)
#define MHD_mutex_unlock_chk_(pmutex)
#define MHD_mutex_lock_chk_(pmutex)
#define MHD_SCKT_ERR_IS_(err, code)
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
#define MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)
#define MHD_socket_last_strerr_()
#define MHD_SCKT_EOPNOTSUPP_
#define MHD_socket_get_error_()
#define MHD_SCKT_ERR_IS_REMOTE_DISCNN_(err)
#define MHD_SCKT_ERR_IS_EINTR_(err)
#define MHD_SCKT_SEND_MAX_SIZE_
#define MHD_SCKT_ENOTCONN_
#define MHD_recv_(s, b, l)
int MHD_str_equal_caseless_(const char *str1, const char *str2)
size_t MHD_str_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
size_t MHD_strx_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
int MHD_str_equal_caseless_n_(const char *const str1, const char *const str2, size_t maxlen)
bool MHD_str_has_token_caseless_(const char *str, const char *const token, size_t token_len)
#define MHD_str_has_s_token_caseless_(str, tkn)
#define MHD_STATICSTR_LEN_(macro)
ssize_t MHD_send_hdr_and_body_(struct MHD_Connection *connection, const char *header, size_t header_size, bool never_push_hdr, const char *body, size_t body_size, bool complete_response)
ssize_t MHD_send_iovec_(struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data)
ssize_t MHD_send_data_(struct MHD_Connection *connection, const char *buffer, size_t buffer_size, bool push_data)
Declarations of send() wrappers.
MHD internal shared structures.
@ MHD_CONNECTION_BODY_RECEIVED
@ MHD_CONNECTION_CHUNKED_BODY_SENT
@ MHD_CONNECTION_REQ_HEADERS_RECEIVING
@ MHD_CONNECTION_BODY_RECEIVING
@ MHD_CONNECTION_HEADERS_SENDING
@ MHD_CONNECTION_FOOTERS_SENDING
@ MHD_CONNECTION_FOOTERS_RECEIVED
@ MHD_CONNECTION_FULL_REPLY_SENT
@ MHD_CONNECTION_HEADERS_SENT
@ MHD_CONNECTION_HEADERS_PROCESSED
@ MHD_CONNECTION_REQ_LINE_RECEIVED
@ MHD_CONNECTION_NORMAL_BODY_UNREADY
@ MHD_CONNECTION_HEADERS_RECEIVED
@ MHD_CONNECTION_NORMAL_BODY_READY
@ MHD_CONNECTION_START_REPLY
@ MHD_CONNECTION_FOOTERS_RECEIVING
@ MHD_CONNECTION_CHUNKED_BODY_READY
@ MHD_CONNECTION_FULL_REQ_RECEIVED
@ MHD_CONNECTION_CHUNKED_BODY_UNREADY
@ MHD_CONNECTION_CONTINUE_SENDING
@ MHD_CONNECTION_REQ_LINE_RECEIVING
@ MHD_TLS_CONN_TLS_CLOSING
@ MHD_TLS_CONN_WR_CLOSING
@ MHD_TLS_CONN_INVALID_STATE
@ MHD_TLS_CONN_TLS_CLOSED
@ MHD_TLS_CONN_TLS_FAILED
@ MHD_TLS_CONN_HANDSHAKING
@ MHD_EVENT_LOOP_INFO_PROCESS_READ
@ MHD_EVENT_LOOP_INFO_PROCESS
@ MHD_EVENT_LOOP_INFO_READ
@ MHD_EVENT_LOOP_INFO_WRITE
@ MHD_EVENT_LOOP_INFO_CLEANUP
struct MHD_IoVec MHD_iovec_
#define MHD_IS_HTTP_VER_SUPPORTED(ver)
_MHD_static_inline struct MHD_Daemon * MHD_get_master(struct MHD_Daemon *const daemon)
@ MHD_RAF_HAS_CONTENT_LENGTH
@ MHD_RAF_HAS_CONNECTION_CLOSE
@ MHD_RAF_HAS_TRANS_ENC_CHUNKED
@ MHD_RAF_HAS_CONNECTION_HDR
#define MHD_IS_HTTP_VER_1_1_COMPAT(ver)
@ MHD_HTTP_MTHD_NO_METHOD
#define MHD_D_IS_USING_THREAD_PER_CONN_(d)
#define MHD_D_IS_USING_THREADS_(d)
#define MHD_D_IS_USING_EPOLL_(d)
bool MHD_pool_is_resizable_inplace(struct MemoryPool *pool, void *block, size_t block_size)
void MHD_pool_deallocate(struct MemoryPool *pool, void *block, size_t block_size)
void * MHD_pool_try_alloc(struct MemoryPool *pool, size_t size, size_t *required_bytes)
memory pool; mostly used for efficient (de)allocation for each connection and bounding memory use for...
Header for platform missing functions.
Header for platform-independent inter-thread communication.
limits values definitions
Header for platform-independent locks abstraction.
uint64_t MHD_monotonic_msec_counter(void)
internal monotonic clock functions implementations
#define MHD_SEND_SPIPE_SUPPRESS_NEEDED
size_t MHD_uint8_to_str_pad(uint8_t val, uint8_t min_digits, char *buf, size_t buf_size)
size_t MHD_uint16_to_str(uint16_t val, char *buf, size_t buf_size)
size_t MHD_uint64_to_str(uint64_t val, char *buf, size_t buf_size)
bool MHD_str_equal_caseless_bin_n_(const char *const str1, const char *const str2, size_t len)
size_t MHD_uint32_to_strx(uint32_t val, char *buf, size_t buf_size)
Header for string manipulating helpers.
#define MHD_thread_handle_ID_is_current_thread_(hndl_id)
bool MHD_add_response_entry_no_alloc_(struct MHD_Response *response, enum MHD_ValueKind kind, char *header, size_t header_len, char *content, size_t content_len)
void MHD_increment_response_rc(struct MHD_Response *response)
#define MHD_CONTENT_READER_END_OF_STREAM
_MHD_EXTERN size_t MHD_get_reason_phrase_len_for(unsigned int code)
#define MHD_INVALID_SOCKET
_MHD_EXTERN const char * MHD_get_reason_phrase_for(unsigned int code)
#define MHD_CONTENT_READER_END_WITH_ERROR
@ MHD_USE_SUPPRESS_DATE_NO_CLOCK
@ MHD_RF_SEND_KEEP_ALIVE_HEADER
@ MHD_RF_HEAD_ONLY_RESPONSE
@ MHD_RF_HTTP_1_0_COMPATIBLE_STRICT
@ MHD_RF_INSANITY_HEADER_CONTENT_LENGTH
@ MHD_CONNECTION_OPTION_TIMEOUT
Methods for managing response objects.
enum MHD_Result MHD_response_execute_upgrade_(struct MHD_Response *response, struct MHD_Connection *connection)
size_t write_buffer_send_offset
enum MHD_ConnectionEventLoopInfo event_loop_info
size_t write_buffer_append_offset
enum MHD_ConnKeepAlive keepalive
union MHD_ConnectionInfo connection_info_dummy
size_t continue_message_write_offset
struct sockaddr_storage addr
size_t read_buffer_offset
enum MHD_CONNECTION_STATE state
struct MHD_Daemon * daemon
uint64_t connection_timeout_ms
MHD_AccessHandlerCallback default_handler
LogCallback uri_log_callback
void * unescape_callback_cls
MHD_mutex_ cleanup_connection_mutex
struct MHD_Connection * connections_head
MHD_RequestCompletedCallback notify_completed
uint64_t connection_timeout_ms
struct MHD_Connection * manual_timeout_tail
UnescapeCallback unescape_callback
void * notify_completed_cls
struct MHD_Connection * cleanup_tail
struct MHD_Daemon * worker_pool
struct MHD_Connection * manual_timeout_head
void * default_handler_cls
struct MHD_Connection * suspended_connections_tail
struct MHD_Connection * cleanup_head
struct MHD_Connection * normal_timeout_head
struct MHD_Connection * normal_timeout_tail
void * uri_log_callback_cls
struct MHD_Connection * suspended_connections_head
struct MHD_Connection * connections_tail
bool use_reply_body_headers
uint64_t rsp_write_position
struct MHD_iovec_track_ resp_iov
struct MHD_Response * response
unsigned int responseCode
struct MHD_Reply_Properties props
unsigned int skipped_empty_lines
union MHD_HeadersProcessing hdrs
uint64_t current_chunk_size
uint64_t current_chunk_offset
struct MHD_HTTP_Header * headers_received
struct MHD_HTTP_Header * headers_received_tail
bool some_payload_processed
size_t skipped_broken_lines
size_t num_cr_sp_replaced
enum MHD_HTTP_Version http_ver
union MHD_StartOrSize field_lines
enum MHD_HTTP_Method http_mthd
uint64_t remaining_upload_size
enum MHD_HTTP_StatusCode status_code
MHD_ContentReaderCallback crc
enum MHD_ResponseAutoFlags flags_auto
enum MHD_ResponseFlags flags
struct MHD_HTTP_Header * first_header
unsigned int connection_timeout
struct MHD_Daemon * daemon
struct sockaddr * client_addr