Go to the documentation of this file.
34 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
35 #include "mhd_locks.h"
40 #ifdef MHD_LINUX_SOLARIS_SENDFILE
41 #include <sys/sendfile.h>
43 #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE)
44 #include <sys/types.h>
45 #include <sys/socket.h>
51 #ifdef HAVE_SYS_PARAM_H
53 #include <sys/param.h>
60 #define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n"
70 #define REQUEST_TOO_BIG \
71 "<html><head><title>Request too big</title></head><body>Your HTTP header was too big for the memory constraints of this webserver.</body></html>"
73 #define REQUEST_TOO_BIG ""
84 #define REQUEST_LACKS_HOST \
85 "<html><head><title>"Host:" header required</title></head><body>In HTTP 1.1, requests must include a "Host:" header, and your HTTP 1.1 request lacked such a header.</body></html>"
87 #define REQUEST_LACKS_HOST ""
98 #define REQUEST_MALFORMED \
99 "<html><head><title>Request malformed</title></head><body>Your HTTP request was syntactically incorrect.</body></html>"
101 #define REQUEST_MALFORMED ""
111 #define INTERNAL_ERROR \
112 "<html><head><title>Internal server error</title></head><body>Please ask the developer of this Web server to carefully read the GNU libmicrohttpd documentation about connection management and blocking.</body></html>"
114 #define INTERNAL_ERROR ""
121 #define DEBUG_CLOSE MHD_NO
126 #define DEBUG_SEND_DATA MHD_NO
132 #define MHD_SENFILE_CHUNK_ (0x20000)
137 #define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000)
139 #ifdef HAVE_FREEBSD_SENDFILE
144 static int freebsd_sendfile_flags_;
149 static int freebsd_sendfile_flags_thd_p_c_;
155 MHD_conn_init_static_ (
void)
161 long sys_page_size = sysconf (_SC_PAGESIZE);
162 if (0 > sys_page_size)
164 freebsd_sendfile_flags_ = SF_NODISKIO;
165 freebsd_sendfile_flags_thd_p_c_ = SF_NODISKIO;
169 freebsd_sendfile_flags_ =
171 freebsd_sendfile_flags_thd_p_c_ =
226 else if (i > (
size_t) ret)
254 if (
NULL == connection)
261 if ( (
NULL != iterator) &&
262 (
MHD_YES != iterator (iterator_cls,
293 if (
NULL == connection)
297 if (
NULL == iterator)
308 if (
MHD_NO == iterator (iterator_cls,
352 pos->
header = (
char *) key;
407 ( ((key ? strlen (key) : 0) != key_size) ||
485 (
NULL == key) ? 0 : strlen (key),
516 const char **value_ptr,
517 size_t *value_size_ptr)
521 if (
NULL == connection)
550 if (
NULL != value_ptr)
551 *value_ptr = pos->
value;
553 if (
NULL != value_size_ptr)
618 #define MHD_lookup_header_s_token_ci(c,h,tkn) \
619 MHD_lookup_header_token_ci ((c),(h),MHD_STATICSTR_LEN_ (h), \
620 (tkn),MHD_STATICSTR_LEN_ (tkn))
716 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
731 struct MHD_UpgradeResponseHandle *urh = connection->urh;
742 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
747 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
749 if (urh->in_eready_list)
752 daemon->eready_urh_tail,
754 urh->in_eready_list =
false;
761 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
766 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
771 shutdown (urh->mhd.socket, SHUT_RDWR);
796 MHD_DLOG (connection->
daemon,
811 #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, emsg)
813 #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, NULL)
846 #if defined(_MHD_HAVE_SENDFILE)
847 if (MHD_resp_sender_sendfile == connection->resp_sender)
865 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
874 "Closing connection (application reported error generating data).\n"));
882 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
918 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
923 _ (
"Closing connection (out of memory).\n"));
926 if ( (2 * (0xFFFFFF +
sizeof(cbuf) + 2)) < size)
927 size = 2 * (0xFFFFFF +
sizeof(cbuf) + 2);
944 const size_t data_write_offset
947 ret = response->
data_size - data_write_offset;
951 &response->
data[data_write_offset],
966 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
971 "Closing connection (application error generating response).\n"));
989 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
996 cblen = MHD_snprintf_ (cbuf,
1002 memcpy (&connection->
write_buffer[sizeof (cbuf) - cblen],
1005 memcpy (&connection->
write_buffer[sizeof (cbuf) + ret],
1085 static const char *
const days[] = {
1086 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
1088 static const char *
const mons[] = {
1089 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
1090 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
1094 #if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \
1095 ! defined(HAVE_GMTIME_R)
1101 #if defined(HAVE_C11_GMTIME_S)
1102 if (
NULL == gmtime_s (&t,
1105 #elif defined(HAVE_W32_GMTIME_S)
1106 if (0 != gmtime_s (&now,
1109 #elif defined(HAVE_GMTIME_R)
1110 if (
NULL == gmtime_r (&t,
1119 MHD_snprintf_ (date,
1121 "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
1122 days[now.tm_wday % 7],
1123 (
unsigned int) now.tm_mday,
1124 mons[now.tm_mon % 12],
1125 (
unsigned int) (1900 + now.tm_year),
1126 (
unsigned int) now.tm_hour,
1127 (
unsigned int) now.tm_min,
1128 (
unsigned int) now.tm_sec);
1152 if (0 == avail_size)
1155 new_size = avail_size / 2;
1160 grow_size = avail_size / 8;
1169 if (small_inc < avail_size)
1170 grow_size = small_inc;
1172 grow_size = avail_size;
1207 char content_length_buf[128];
1208 size_t content_length_len;
1211 const char *reason_phrase;
1213 bool client_requested_close;
1214 bool response_has_close;
1215 bool response_has_keepalive;
1216 const char *have_encoding;
1217 bool must_add_close;
1218 bool must_add_chunked_encoding;
1219 bool must_add_keep_alive;
1220 bool must_add_content_length;
1221 bool may_add_content_length;
1224 if (0 == connection->
version[0])
1239 off = MHD_snprintf_ (code,
1263 datelen = strlen (date);
1277 must_add_close =
false;
1278 must_add_chunked_encoding =
false;
1279 must_add_keep_alive =
false;
1280 must_add_content_length =
false;
1281 response_has_close =
false;
1282 switch (connection->
state)
1297 #ifdef UPGRADE_SUPPORT
1298 else if (
NULL != response->upgrade_handler)
1307 if (
NULL == have_encoding)
1308 may_add_content_length =
true;
1310 may_add_content_length =
false;
1312 #ifdef UPGRADE_SUPPORT
1313 (
NULL == response->upgrade_handler) &&
1315 (! response_has_close) &&
1316 (! client_requested_close) )
1327 if (
NULL == have_encoding)
1329 must_add_chunked_encoding =
true;
1338 must_add_close =
true;
1351 must_add_close =
true;
1356 if ( ( (client_requested_close) ||
1359 (! response_has_close) &&
1360 #ifdef UPGRADE_SUPPORT
1361 (
NULL == response->upgrade_handler) &&
1364 must_add_close =
true;
1368 if ( (! may_add_content_length) &&
1370 (! response_has_close) )
1371 must_add_close =
true;
1384 (may_add_content_length) &&
1404 = MHD_snprintf_ (content_length_buf,
1405 sizeof (content_length_buf),
1409 must_add_content_length =
true;
1413 if ( (! response_has_keepalive) &&
1414 (! response_has_close) &&
1415 (! must_add_close) &&
1417 #ifdef UPGRADE_SUPPORT
1418 (
NULL == response->upgrade_handler) &&
1421 must_add_keep_alive =
true;
1424 response_has_keepalive =
false;
1433 if ( (must_add_close) || (response_has_close) )
1435 else if ( (must_add_keep_alive) || (response_has_keepalive) )
1441 if (must_add_keep_alive)
1443 if (must_add_chunked_encoding)
1445 if (must_add_content_length)
1446 size += content_length_len;
1447 mhd_assert (! (must_add_close && must_add_keep_alive) );
1448 mhd_assert (! (must_add_chunked_encoding && must_add_content_length) );
1454 (! ( (must_add_close) &&
1455 (response_has_keepalive) &&
1463 "Keep-Alive")) ) ) )
1472 #ifdef HAVE_MESSAGES
1473 MHD_DLOG (connection->
daemon,
1474 "Not enough memory for write!\n");
1488 "Connection: close\r\n",
1492 if (must_add_keep_alive)
1496 "Connection: Keep-Alive\r\n",
1500 if (must_add_chunked_encoding)
1504 "Transfer-Encoding: chunked\r\n",
1508 if (must_add_content_length)
1513 content_length_len);
1514 off += content_length_len;
1520 (! ( (must_add_close) &&
1521 (response_has_keepalive) &&
1529 "Keep-Alive")) ) ) )
1530 off += MHD_snprintf_ (&
data[off],
1572 unsigned int status_code,
1573 const char *message)
1596 #ifdef HAVE_MESSAGES
1597 MHD_DLOG (connection->
daemon,
1599 "Error processing request (HTTP response code is %u (`%s')). Closing connection.\n"),
1611 if (
NULL == response)
1626 "Closing connection (failed to queue response).\n"));
1637 "Closing connection (failed to create response header).\n"));
1660 #ifdef HTTPS_SUPPORT
1663 switch (connection->tls_state)
1669 if (0 == gnutls_record_get_direction (connection->tls_session))
1682 MHD_DLOG (connection->
daemon,
1683 _ (
"In function %s handling connection at state: %s\n"),
1685 MHD_state_to_string (connection->
state));
1687 switch (connection->
state)
1721 const bool internal_poll = (0 != (connection->
daemon->
options
1796 #ifdef UPGRADE_SUPPORT
1797 case MHD_CONNECTION_UPGRADE:
1833 while ( (pos < connection->read_buffer_offset - 1) &&
1834 (
'\r' != rbuf[pos]) &&
1835 (
'\n' != rbuf[pos]) )
1838 (
'\n' != rbuf[pos]) )
1858 if ( (
'\r' == rbuf[pos]) &&
1859 (
'\n' == rbuf[pos + 1]) )
1898 #ifdef HAVE_MESSAGES
1899 MHD_DLOG (connection->
daemon,
1900 _ (
"Not enough memory in pool to allocate header record!\n"));
1945 #ifdef HAVE_MESSAGES
1946 MHD_DLOG (connection->
daemon,
1947 _ (
"Not enough memory in pool to parse cookies!\n"));
1957 cpy[hdr_len] =
'\0';
1965 while ( ((*sce) !=
'\0') &&
1972 while ( (*ekill ==
' ') &&
1996 while ( (
'\0' != semicolon[0]) &&
1998 ( (
';' != semicolon[0]) &&
1999 (
',' != semicolon[0]) ) ) )
2001 if (
'"' == semicolon[0])
2002 quotes = (quotes + 1) & 1;
2006 if (
'\0' == semicolon[0])
2008 if (
NULL != semicolon)
2010 semicolon[0] =
'\0';
2014 if ( (
'"' == equals[0]) &&
2053 unsigned int unused_num_headers;
2055 if (
NULL == (uri = memchr (line,
2060 connection->
method = line;
2064 while ( (
' ' == uri[0]) &&
2065 ( (
size_t) (uri - line) < line_len) )
2067 if ((
size_t) (uri - line) == line_len)
2080 http_version = line + line_len - 1;
2082 while ( (
' ' == http_version[0]) &&
2083 (http_version > uri) )
2086 while ( (
' ' != http_version[0]) &&
2087 (http_version > uri) )
2089 if (http_version > uri)
2092 http_version[0] =
'\0';
2093 connection->
version = http_version + 1;
2094 uri_len = http_version - uri;
2099 uri_len = line_len - (uri - line);
2103 (
NULL != memchr (uri,
2135 &unused_num_headers);
2143 connection->
url = curi;
2178 "Application reported internal error, closing connection.\n"));
2218 size_t to_be_processed;
2219 size_t left_unprocessed;
2220 size_t processed_size;
2234 if ( (
'\r' == buffer_head[i]) ||
2235 (
'\n' == buffer_head[i]) )
2237 if ( (
'\r' == buffer_head[i]) ||
2238 (
'\n' == buffer_head[i]) )
2245 "Received malformed HTTP request (bad chunked encoding). Closing connection.\n"));
2256 uint64_t cur_chunk_left;
2262 if (cur_chunk_left > available)
2263 to_be_processed = available;
2266 to_be_processed = (size_t) cur_chunk_left;
2267 if (available > to_be_processed)
2279 while (i < available)
2281 if ( (
'\r' == buffer_head[i]) ||
2282 (
'\n' == buffer_head[i]) ||
2283 (
';' == buffer_head[i]) )
2291 if (
';' == buffer_head[i])
2293 while (i < available)
2295 if ( (
'\r' == buffer_head[i]) ||
2296 (
'\n' == buffer_head[i]) )
2304 if ( (i + 1 >= available) &&
2307 (
'0' == buffer_head[0]) ) )
2310 malformed = (end_size >= 16);
2316 current_chunk_size);
2317 malformed = (end_size != num_dig);
2324 "Received malformed HTTP request (bad chunked encoding). Closing connection.\n"));
2328 if ( (i < available) &&
2329 ( (
'\r' == buffer_head[i]) ||
2330 (
'\n' == buffer_head[i]) ) )
2362 to_be_processed = available;
2365 left_unprocessed = to_be_processed;
2380 "Application reported internal error, closing connection.\n"));
2383 if (left_unprocessed > to_be_processed)
2387 #ifdef HAVE_MESSAGES
2388 ,
_ (
"libmicrohttpd API violation.\n")
2393 if (0 != left_unprocessed)
2396 #ifdef HAVE_MESSAGES
2404 "WARNING: incomplete upload processing and connection not suspended may result in hung connection.\n"));
2407 processed_size = to_be_processed - left_unprocessed;
2411 buffer_head += processed_size;
2412 available -= processed_size;
2416 while (
MHD_YES == instant_retry);
2417 if ( (available > 0) &&
2443 connection->
state = next_state;
2470 colon = strchr (line,
':');
2476 "Received malformed line (no colon). Closing connection.\n"));
2486 white = strchr (line,
' ');
2487 if ( (
NULL != white) &&
2490 white = strchr (line,
'\t');
2491 if ( (
NULL != white) &&
2498 while ( (
'\0' != colon[0]) &&
2499 ( (
' ' == colon[0]) ||
2500 (
'\t' == colon[0]) ) )
2506 connection->
last = line;
2507 connection->
colon = colon;
2532 last = connection->
last;
2533 if ( (
' ' == line[0]) ||
2538 last_len = strlen (last);
2541 while ( (
' ' == tmp[0]) ||
2544 tmp_len = strlen (tmp);
2556 last_len + tmp_len + 1);
2564 memcpy (&last[last_len],
2567 connection->
last = last;
2577 strlen (connection->
colon),
2635 #ifdef HAVE_MESSAGES
2636 MHD_DLOG (connection->
daemon,
2637 _ (
"Received HTTP 1.1 request without `Host' header.\n"));
2644 if (
NULL == response)
2649 "Closing connection (failed to create response).\n"));
2661 "Closing connection (failed to queue response).\n"));
2692 if ( (clen == end) ||
2696 #ifdef HAVE_MESSAGES
2697 MHD_DLOG (connection->
daemon,
2698 "Failed to parse `Content-Length' header. Closing connection.\n");
2733 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
2743 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
2763 #ifdef HTTPS_SUPPORT
2784 bytes_read = connection->
recv_cls (connection,
2799 "Socket disconnected while reading request.\n"));
2806 "Connection socket is closed due to error when reading request.\n"));
2810 if (0 == bytes_read)
2820 MHD_DLOG (connection->
daemon,
2821 _ (
"In function %s handling connection at state: %s\n"),
2823 MHD_state_to_string (connection->
state));
2825 switch (connection->
state)
2845 #ifdef UPGRADE_SUPPORT
2846 case MHD_CONNECTION_UPGRADE:
2876 #ifdef HTTPS_SUPPORT
2888 MHD_DLOG (connection->
daemon,
2889 _ (
"In function %s handling connection at state: %s\n"),
2891 MHD_state_to_string (connection->
state));
2893 switch (connection->
state)
2914 #ifdef HAVE_MESSAGES
2915 MHD_DLOG (connection->
daemon,
2916 _ (
"Failed to send data in request for %s.\n"),
2925 _ (
"Sent 100 continue response: `%.*s'\n"),
2968 "Connection was closed while sending response headers.\n"));
2996 uint64_t data_write_offset;
2998 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3007 #if defined(_MHD_HAVE_SENDFILE)
3008 if (MHD_resp_sender_sendfile == connection->resp_sender)
3010 ret = MHD_send_sendfile_ (connection);
3019 if (data_write_offset > (uint64_t)
SIZE_MAX)
3020 MHD_PANIC (
_ (
"Data offset exceeds limit.\n"));
3023 [(
size_t) data_write_offset],
3025 - (
size_t) data_write_offset,
3030 _ (
"Sent %d-byte DATA response: `%.*s'\n"),
3037 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3045 #ifdef HAVE_MESSAGES
3046 MHD_DLOG (connection->
daemon,
3047 _ (
"Failed to send data in request for `%s'.\n"),
3077 "Connection was closed while sending response body.\n"));
3107 "Connection was closed while sending response body.\n"));
3122 #ifdef UPGRADE_SUPPORT
3123 case MHD_CONNECTION_UPGRADE:
3130 _ (
"Internal error.\n"));
3158 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3190 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3198 if ( (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
3199 (! MHD_itc_activate_ (daemon->
itc,
"c")) )
3201 #ifdef HAVE_MESSAGES
3204 "Failed to signal end of connection via inter-thread communication channel.\n"));
3232 #ifdef HTTPS_SUPPORT
3235 if ((MHD_TLS_CONN_INIT <= connection->tls_state) &&
3242 _ (
"In function %s handling connection at state: %s\n"),
3244 MHD_state_to_string (connection->
state));
3246 switch (connection->
state)
3255 if ( (
NULL == line) ||
3469 "Closing connection (failed to create response header).\n"));
3479 #ifdef UPGRADE_SUPPORT
3482 connection->
state = MHD_CONNECTION_UPGRADE;
3513 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3519 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3528 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3544 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3552 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3561 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3578 "Closing connection (failed to create response header).\n"));
3664 #ifdef UPGRADE_SUPPORT
3665 case MHD_CONNECTION_UPGRADE:
3679 if ( (0 != timeout) &&
3691 #ifdef EPOLL_SUPPORT
3695 ret = MHD_connection_epoll_update_ (connection);
3703 #ifdef EPOLL_SUPPORT
3726 struct epoll_event event;
3728 event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET;
3729 event.data.ptr = connection;
3730 if (0 != epoll_ctl (daemon->epoll_fd,
3735 #ifdef HAVE_MESSAGES
3738 _ (
"Call to epoll_ctl failed: %s\n"),
3783 #ifdef HTTPS_SUPPORT
3785 if (
NULL == connection->tls_session)
3787 connection->cipher = gnutls_cipher_get (connection->tls_session);
3790 if (
NULL == connection->tls_session)
3792 connection->protocol = gnutls_protocol_get_version (
3793 connection->tls_session);
3796 if (
NULL == connection->tls_session)
3815 connection_timeout_dummy;
3844 daemon = connection->
daemon;
3850 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3865 va_start (ap, option);
3881 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3904 unsigned int status_code,
3909 if ( (
NULL == connection) ||
3910 (
NULL == response) ||
3915 daemon = connection->
daemon;
3921 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3924 (! MHD_thread_ID_match_current_ (connection->
pid.ID)) )
3926 #ifdef HAVE_MESSAGES
3928 _ (
"Attempted to queue response on wrong thread!\n"));
3933 #ifdef UPGRADE_SUPPORT
3934 if ( (
NULL != response->upgrade_handler) &&
3937 #ifdef HAVE_MESSAGES
3940 "Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n"));
3945 (
NULL != response->upgrade_handler) )
3947 #ifdef HAVE_MESSAGES
3950 "Application used invalid status code for 'upgrade' response!\n"));
3958 #if defined(_MHD_HAVE_SENDFILE)
3959 if ( (response->
fd == -1) ||
3961 connection->resp_sender = MHD_resp_sender_std;
3963 connection->resp_sender = MHD_resp_sender_sendfile;
struct MHD_HTTP_Header * first_header
bool MHD_str_equal_caseless_bin_n_(const char *const str1, const char *const str2, size_t len)
Header for platform missing functions.
@ MHD_CONNECTION_CONTINUE_SENDING
static char * get_next_header_line(struct MHD_Connection *connection, size_t *line_len)
static enum MHD_Result build_header_response(struct MHD_Connection *connection)
LogCallback uri_log_callback
static enum MHD_Result parse_initial_message_line(struct MHD_Connection *connection, char *line, size_t line_len)
UnescapeCallback unescape_callback
@ MHD_CONNECTION_INFO_PROTOCOL
@ MHD_CONN_KEEPALIVE_UNKOWN
limits values definitions
static enum MHD_Result check_write_done(struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state)
#define MHD_CONTENT_READER_END_WITH_ERROR
@ MHD_CONNECTION_NORMAL_BODY_UNREADY
@ MHD_CONNECTION_BODY_SENT
@ MHD_CONNECTION_NORMAL_BODY_READY
#define MHD_mutex_unlock_chk_(pmutex)
static void call_connection_handler(struct MHD_Connection *connection)
@ MHD_CONNECTION_CHUNKED_BODY_UNREADY
static enum MHD_Result process_header_line(struct MHD_Connection *connection, char *line)
@ MHD_EPOLL_STATE_WRITE_READY
@ MHD_RF_HTTP_VERSION_1_0_ONLY
static void transmit_error_response(struct MHD_Connection *connection, unsigned int status_code, const char *message)
struct MHD_Connection * cleanup_tail
@ MHD_CONNECTION_INFO_GNUTLS_SESSION
@ MHD_CONNECTION_OPTION_TIMEOUT
enum MHD_Result MHD_connection_handle_idle(struct MHD_Connection *connection)
ssize_t MHD_send_on_connection2_(struct MHD_Connection *connection, const char *header, size_t header_size, const char *buffer, size_t buffer_size)
struct MHD_Connection * manual_timeout_tail
void MHD_update_last_activity_(struct MHD_Connection *connection)
void MHD_connection_finish_forward_(struct MHD_Connection *connection) MHD_NONNULL(1)
static enum MHD_Result try_ready_normal_body(struct MHD_Connection *connection)
@ MHD_REQUEST_TERMINATED_READ_ERROR
#define MHD_UNSIGNED_LONG_LONG
#define MHD_HTTP_NOT_MODIFIED
bool MHD_parse_arguments_(struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
time_t MHD_monotonic_sec_counter(void)
@ MHD_EVENT_LOOP_INFO_BLOCK
unsigned int connection_timeout_dummy
@ MHD_CONNECTION_INFO_CONNECTION_TIMEOUT
struct MHD_Connection * normal_timeout_tail
ssize_t MHD_send_on_connection_(struct MHD_Connection *connection, const char *buffer, size_t buffer_size, enum MHD_SendSocketOptions options)
static ssize_t recv_param_adapter(struct MHD_Connection *connection, void *other, size_t i)
static void MHD_connection_update_event_loop_info(struct MHD_Connection *connection)
size_t write_buffer_append_offset
@ MHD_CONNECTION_URL_RECEIVED
@ MHD_CONNECTION_FOOTERS_RECEIVED
_MHD_EXTERN const char * MHD_get_reason_phrase_for(unsigned int code)
static void cleanup_connection(struct MHD_Connection *connection)
struct MHD_Connection * normal_timeout_head
void * notify_completed_cls
memory pool; mostly used for efficient (de)allocation for each connection and bounding memory use for...
static enum MHD_Result keepalive_possible(struct MHD_Connection *connection)
static enum MHD_Result process_broken_line(struct MHD_Connection *connection, char *line, enum MHD_ValueKind kind)
@ MHD_REQUEST_TERMINATED_COMPLETED_OK
bool MHD_run_tls_handshake_(struct MHD_Connection *connection)
#define MHD_recv_(s, b, l)
enum MHD_Result(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
enum MHD_HTTP_StatusCode status_code
_MHD_EXTERN int MHD_get_connection_values(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
Methods for managing connections.
@ MHD_CONNECTION_HEADERS_PROCESSED
static bool need_100_continue(struct MHD_Connection *connection)
MHD_ContentReaderCallback crc
_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)
Methods for managing response objects.
struct MHD_Connection * suspended_connections_tail
#define MHD_INVALID_SOCKET
void * MHD_pool_reset(struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size)
_MHD_EXTERN enum MHD_Result MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
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)
internal shared structures
struct MHD_Connection * suspended_connections_head
#define MHD_HTTP_URI_TOO_LONG
@ MHD_CONNECTION_CHUNKED_BODY_READY
enum MHD_Result MHD_response_execute_upgrade_(struct MHD_Response *response, struct MHD_Connection *connection)
int MHD_str_equal_caseless_(const char *str1, const char *str2)
@ MHD_RF_HTTP_VERSION_1_0_RESPONSE
MHD_RequestCompletedCallback notify_completed
@ MHD_CONNECTION_INFO_CIPHER_ALGO
uint64_t current_chunk_size
@ MHD_REQUEST_TERMINATED_CLIENT_ABORT
#define MHD_socket_get_error_()
bool MHD_str_has_token_caseless_(const char *str, const char *const token, size_t token_len)
#define REQUEST_MALFORMED
static bool try_grow_read_buffer(struct MHD_Connection *connection, bool required)
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 MHD_SCKT_ERR_IS_(err, code)
@ MHD_EPOLL_STATE_IN_EPOLL_SET
internal monotonic clock functions implementations
_MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
struct MHD_HTTP_Header * headers_received_tail
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
#define MHD_HTTP_NO_CONTENT
@ MHD_EVENT_LOOP_INFO_READ
void MHD_connection_handle_write(struct MHD_Connection *connection)
#define EDLL_remove(head, tail, element)
_MHD_EXTERN int MHD_get_connection_values_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls)
#define MHD_ERR_CONNRESET_
size_t read_buffer_offset
static enum MHD_Result connection_add_header(struct MHD_Connection *connection, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind)
void * default_handler_cls
#define DLL_insert(head, tail, element)
void MHD_connection_mark_closed_(struct MHD_Connection *connection)
struct MHD_HTTP_Header * headers_received
uint64_t current_chunk_offset
size_t MHD_strx_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
struct sockaddr_storage addr
time_t connection_timeout
void * MHD_pool_reallocate(struct MemoryPool *pool, void *old, size_t old_size, size_t new_size)
#define DLL_remove(head, tail, element)
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
enum MHD_CONNECTION_STATE state
#define REQUEST_LACKS_HOST
void MHD_pool_destroy(struct MemoryPool *pool)
#define MHD_socket_last_strerr_()
MHD_mutex_ cleanup_connection_mutex
enum MHD_ConnKeepAlive keepalive
@ MHD_CONNECTION_INFO_CONNECTION_SUSPENDED
@ MHD_USE_SUPPRESS_DATE_NO_CLOCK
#define MHD_check_response_header_s_token_ci(r, k, tkn)
#define MHD_HTTP_VERSION_1_1
#define MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
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)
void MHD_increment_response_rc(struct MHD_Response *response)
static void process_request_body(struct MHD_Connection *connection)
@ MHD_USE_INTERNAL_POLLING_THREAD
#define CONNECTION_CLOSE_ERROR(c, emsg)
@ MHD_CONNECTION_CONTINUE_SENT
_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)
struct MHD_Connection * manual_timeout_head
#define MHD_SENFILE_CHUNK_THR_P_C_
@ MHD_TLS_CONN_HANDSHAKING
_MHD_EXTERN enum MHD_Result MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
@ MHD_CONNECTION_FOOTER_PART_RECEIVED
#define MHD_CONTENT_READER_END_OF_STREAM
void * unescape_callback_cls
@ MHD_CONNECTION_INFO_CONNECTION_FD
uint64_t response_write_position
struct MHD_Connection * cleanup_head
_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_ConnectionEventLoopInfo event_loop_info
static void parse_connection_headers(struct MHD_Connection *connection)
@ MHD_EVENT_LOOP_INFO_CLEANUP
static enum MHD_Result parse_cookie_header(struct MHD_Connection *connection)
#define MHD_HTTP_BAD_REQUEST
Methods for managing connections.
MHD_AccessHandlerCallback default_handler
#define HTTP_100_CONTINUE
@ MHD_EPOLL_STATE_READ_READY
static void connection_close_error(struct MHD_Connection *connection, const char *emsg)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
#define MHD_HTTP_METHOD_CONNECT
uint64_t remaining_upload_size
struct MHD_Response * response
void MHD_connection_close_(struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code)
#define MHD_STATICSTR_LEN_(macro)
#define MHD_SENFILE_CHUNK_
#define MHD_HTTP_VERSION_1_0
#define MHD_mutex_lock_chk_(pmutex)
Header for string manipulating helpers.
@ MHD_CONNECTION_BODY_RECEIVED
void MHD_connection_handle_read(struct MHD_Connection *connection)
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
#define XDLL_remove(head, tail, element)
struct MHD_Daemon * daemon
MHD_thread_handle_ID_ pid
@ MHD_CONNECTION_FOOTERS_SENT
struct MHD_Connection * connections_tail
@ MHD_CONNECTION_INFO_CLIENT_ADDRESS
MHD_RequestTerminationCode
#define XDLL_insert(head, tail, element)
size_t MHD_pool_get_free(struct MemoryPool *pool)
@ MHD_CONNECTION_HEADERS_RECEIVED
@ MHD_REQUEST_TERMINATED_WITH_ERROR
#define MHD_lookup_header_s_token_ci(c, h, tkn)
#define MHD_HTTP_PROCESSING
@ MHD_CONNECTION_HEADERS_SENDING
@ MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE
@ MHD_USE_THREAD_PER_CONNECTION
unsigned int responseCode
Header for platform-independent inter-thread communication.
size_t write_buffer_send_offset
static void get_date_string(char *date, size_t date_len)
struct MHD_Connection * connections_head
@ MHD_REQUEST_TERMINATED_TIMEOUT_REACHED
void * uri_log_callback_cls
_MHD_EXTERN const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
#define MHD_SCKT_ECONNRESET_
#define MHD_HTTP_INTERNAL_SERVER_ERROR
#define MHD_UNSIGNED_LONG_LONG_PRINTF
Implementation of send() wrappers.
bool MHD_tls_connection_shutdown(struct MHD_Connection *connection)
#define MHD_HTTP_SWITCHING_PROTOCOLS
enum MHD_ResponseFlags flags
@ MHD_CONNECTION_INFO_DAEMON
void * MHD_pool_allocate(struct MemoryPool *pool, size_t size, int from_end)
size_t MHD_str_to_uint64_(const char *str, uint64_t *out_val)
@ MHD_EPOLL_STATE_SUSPENDED
#define MHD_SCKT_ERR_IS_EINTR_(err)
@ MHD_CONNECTION_HEADER_PART_RECEIVED
time_t connection_timeout
void MHD_set_http_callbacks_(struct MHD_Connection *connection)
static enum MHD_Result try_ready_chunked_body(struct MHD_Connection *connection)
MHD_PanicCallback mhd_panic
#define MHD_SCKT_SEND_MAX_SIZE_
@ MHD_CONNECTION_HEADERS_SENT
size_t continue_message_write_offset
@ MHD_EVENT_LOOP_INFO_WRITE
#define MHD_HTTP_METHOD_HEAD
@ MHD_CONNECTION_INFO_SOCKET_CONTEXT
@ MHD_CONNECTION_FOOTERS_SENDING