35 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 36 #include "mhd_locks.h" 41 #ifdef MHD_LINUX_SOLARIS_SENDFILE 42 #include <sys/sendfile.h> 44 #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE) 45 #include <sys/types.h> 46 #include <sys/socket.h> 52 #ifdef HAVE_SYS_PARAM_H 54 #include <sys/param.h> 61 #define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" 71 #define REQUEST_TOO_BIG \ 72 "<html><head><title>Request too big</title></head><body>Your HTTP header was too big for the memory constraints of this webserver.</body></html>" 74 #define REQUEST_TOO_BIG "" 85 #define REQUEST_LACKS_HOST \ 86 "<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>" 88 #define REQUEST_LACKS_HOST "" 99 #define REQUEST_MALFORMED \ 100 "<html><head><title>Request malformed</title></head><body>Your HTTP request was syntactically incorrect.</body></html>" 102 #define REQUEST_MALFORMED "" 112 #define INTERNAL_ERROR \ 113 "<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>" 115 #define INTERNAL_ERROR "" 122 #define DEBUG_CLOSE MHD_NO 127 #define DEBUG_SEND_DATA MHD_NO 133 #define MHD_SENFILE_CHUNK_ (0x20000) 138 #define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) 140 #ifdef HAVE_FREEBSD_SENDFILE 145 static int freebsd_sendfile_flags_;
150 static int freebsd_sendfile_flags_thd_p_c_;
156 MHD_conn_init_static_ (
void)
162 long sys_page_size = sysconf (_SC_PAGESIZE);
163 if (0 > sys_page_size)
165 freebsd_sendfile_flags_ = SF_NODISKIO;
166 freebsd_sendfile_flags_thd_p_c_ = SF_NODISKIO;
170 freebsd_sendfile_flags_ =
172 freebsd_sendfile_flags_thd_p_c_ =
225 else if (i > (
size_t) ret)
279 else if (i > (
size_t) ret)
307 if (
NULL == connection)
314 if ( (
NULL != iterator) &&
315 (
MHD_YES != iterator (iterator_cls,
346 if (
NULL == connection)
350 if (
NULL == iterator)
361 if (
MHD_NO == iterator (iterator_cls,
405 pos->
header = (
char *) key;
460 ( ((key ? strlen (key) : 0) != key_size) ||
538 (
NULL == key) ? 0 : strlen (key),
569 const char **value_ptr,
570 size_t *value_size_ptr)
574 if (
NULL == connection)
603 if (
NULL != value_ptr)
604 *value_ptr = pos->
value;
606 if (
NULL != value_size_ptr)
669 #define MHD_lookup_header_s_token_ci(c,h,tkn) \ 670 MHD_lookup_header_token_ci ((c),(h),MHD_STATICSTR_LEN_ (h), \ 671 (tkn),MHD_STATICSTR_LEN_ (tkn)) 771 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 786 struct MHD_UpgradeResponseHandle *urh = connection->urh;
797 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
802 MHD_PANIC (
_ (
"Failed to remove FD from epoll set\n"));
804 if (urh->in_eready_list)
807 daemon->eready_urh_tail,
809 urh->in_eready_list =
false;
816 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
821 MHD_PANIC (
_ (
"Failed to remove FD from epoll set\n"));
826 shutdown (urh->mhd.socket, SHUT_RDWR);
850 MHD_DLOG (connection->
daemon,
865 #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, emsg) 867 #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, NULL) 900 #if defined(_MHD_HAVE_SENDFILE) 901 if (MHD_resp_sender_sendfile == connection->resp_sender)
919 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 928 "Closing connection (application reported error generating data)\n"));
936 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 972 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 977 _ (
"Closing connection (out of memory)\n"));
980 if ( (2 * (0xFFFFFF +
sizeof(cbuf) + 2)) < size)
981 size = 2 * (0xFFFFFF +
sizeof(cbuf) + 2);
998 const size_t data_write_offset
1001 ret = response->
data_size - data_write_offset;
1005 &response->
data[data_write_offset],
1020 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 1025 "Closing connection (application error generating response)\n"));
1043 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 1050 cblen = MHD_snprintf_ (cbuf,
1053 (
unsigned int) ret);
1056 memcpy (&connection->
write_buffer[sizeof (cbuf) - cblen],
1059 memcpy (&connection->
write_buffer[sizeof (cbuf) + ret],
1139 static const char *
const days[] = {
1140 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat" 1142 static const char *
const mons[] = {
1143 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
1144 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" 1148 #if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \ 1149 ! defined(HAVE_GMTIME_R) 1155 #if defined(HAVE_C11_GMTIME_S) 1156 if (
NULL == gmtime_s (&t,
1159 #elif defined(HAVE_W32_GMTIME_S) 1160 if (0 != gmtime_s (&now,
1163 #elif defined(HAVE_GMTIME_R) 1164 if (
NULL == gmtime_r (&t,
1173 MHD_snprintf_ (date,
1175 "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
1176 days[now.tm_wday % 7],
1177 (
unsigned int) now.tm_mday,
1178 mons[now.tm_mon % 12],
1179 (
unsigned int) (1900 + now.tm_year),
1180 (
unsigned int) now.tm_hour,
1181 (
unsigned int) now.tm_min,
1182 (
unsigned int) now.tm_sec);
1206 if (0 == avail_size)
1209 new_size = avail_size / 2;
1214 grow_size = avail_size / 8;
1223 if (small_inc < avail_size)
1224 grow_size = small_inc;
1226 grow_size = avail_size;
1261 char content_length_buf[128];
1262 size_t content_length_len;
1265 const char *reason_phrase;
1267 bool client_requested_close;
1268 bool response_has_close;
1269 bool response_has_keepalive;
1270 const char *have_encoding;
1271 bool must_add_close;
1272 bool must_add_chunked_encoding;
1273 bool must_add_keep_alive;
1274 bool must_add_content_length;
1275 bool may_add_content_length;
1278 if (0 == connection->
version[0])
1293 off = MHD_snprintf_ (code,
1317 datelen = strlen (date);
1331 must_add_close =
false;
1332 must_add_chunked_encoding =
false;
1333 must_add_keep_alive =
false;
1334 must_add_content_length =
false;
1335 response_has_close =
false;
1336 switch (connection->
state)
1351 #ifdef UPGRADE_SUPPORT 1352 else if (
NULL != response->upgrade_handler)
1361 if (
NULL == have_encoding)
1362 may_add_content_length =
true;
1364 may_add_content_length =
false;
1366 #ifdef UPGRADE_SUPPORT
1367 (
NULL == response->upgrade_handler) &&
1369 (! response_has_close) &&
1370 (! client_requested_close) )
1381 if (
NULL == have_encoding)
1383 must_add_chunked_encoding =
true;
1392 must_add_close =
true;
1404 if (! response_has_close)
1405 must_add_close =
true;
1410 if ( ( (client_requested_close) ||
1413 (! response_has_close) &&
1414 #ifdef UPGRADE_SUPPORT
1415 (
NULL == response->upgrade_handler) &&
1418 must_add_close =
true;
1422 if ( (! may_add_content_length) &&
1424 (! response_has_close) )
1425 must_add_close =
true;
1438 (may_add_content_length) &&
1459 = MHD_snprintf_ (content_length_buf,
1460 sizeof (content_length_buf),
1464 must_add_content_length =
true;
1468 if ( (! response_has_keepalive) &&
1469 (! response_has_close) &&
1470 (! must_add_close) &&
1472 #ifdef UPGRADE_SUPPORT
1473 (
NULL == response->upgrade_handler) &&
1476 must_add_keep_alive =
true;
1479 response_has_keepalive =
false;
1488 if ( (must_add_close) || (response_has_close) )
1490 else if ( (must_add_keep_alive) || (response_has_keepalive) )
1496 if (must_add_keep_alive)
1498 if (must_add_chunked_encoding)
1500 if (must_add_content_length)
1501 size += content_length_len;
1502 mhd_assert (! (must_add_close && must_add_keep_alive) );
1503 mhd_assert (! (must_add_chunked_encoding && must_add_content_length) );
1509 (! ( (must_add_close) &&
1510 (response_has_keepalive) &&
1518 "Keep-Alive")) ) ) )
1527 #ifdef HAVE_MESSAGES 1528 MHD_DLOG (connection->
daemon,
1529 "Not enough memory for write!\n");
1543 "Connection: close\r\n",
1547 if (must_add_keep_alive)
1551 "Connection: Keep-Alive\r\n",
1555 if (must_add_chunked_encoding)
1559 "Transfer-Encoding: chunked\r\n",
1563 if (must_add_content_length)
1568 content_length_len);
1569 off += content_length_len;
1575 (! ( (must_add_close) &&
1576 (response_has_keepalive) &&
1584 "Keep-Alive")) ) ) )
1585 off += MHD_snprintf_ (&
data[off],
1627 unsigned int status_code,
1628 const char *message)
1651 #ifdef HAVE_MESSAGES 1652 MHD_DLOG (connection->
daemon,
1654 "Error processing request (HTTP response code is %u (`%s')). Closing connection.\n"),
1666 if (
NULL == response)
1681 "Closing connection (failed to queue response)\n"));
1692 "Closing connection (failed to create response header)\n"));
1715 #ifdef HTTPS_SUPPORT 1718 switch (connection->tls_state)
1724 if (0 == gnutls_record_get_direction (connection->tls_session))
1737 MHD_DLOG (connection->
daemon,
1738 _ (
"In function %s handling connection at state: %s\n"),
1740 MHD_state_to_string (connection->
state));
1742 switch (connection->
state)
1776 const bool internal_poll = (0 != (connection->
daemon->
options 1852 #ifdef UPGRADE_SUPPORT 1853 case MHD_CONNECTION_UPGRADE:
1889 while ( (pos < connection->read_buffer_offset - 1) &&
1890 (
'\r' != rbuf[pos]) &&
1891 (
'\n' != rbuf[pos]) )
1894 (
'\n' != rbuf[pos]) )
1914 if ( (
'\r' == rbuf[pos]) &&
1915 (
'\n' == rbuf[pos + 1]) )
1954 #ifdef HAVE_MESSAGES 1955 MHD_DLOG (connection->
daemon,
1956 _ (
"Not enough memory in pool to allocate header record!\n"));
2001 #ifdef HAVE_MESSAGES 2002 MHD_DLOG (connection->
daemon,
2003 _ (
"Not enough memory in pool to parse cookies!\n"));
2013 cpy[hdr_len] =
'\0';
2021 while ( ((*sce) !=
'\0') &&
2028 while ( (*ekill ==
' ') &&
2052 while ( (
'\0' != semicolon[0]) &&
2054 ( (
';' != semicolon[0]) &&
2055 (
',' != semicolon[0]) ) ) )
2057 if (
'"' == semicolon[0])
2058 quotes = (quotes + 1) & 1;
2062 if (
'\0' == semicolon[0])
2064 if (
NULL != semicolon)
2066 semicolon[0] =
'\0';
2070 if ( (
'"' == equals[0]) &&
2109 unsigned int unused_num_headers;
2111 if (
NULL == (uri = memchr (line,
2116 connection->
method = line;
2120 while ( (
' ' == uri[0]) &&
2121 ( (
size_t) (uri - line) < line_len) )
2123 if ((
size_t) (uri - line) == line_len)
2136 http_version = line + line_len - 1;
2138 while ( (
' ' == http_version[0]) &&
2139 (http_version > uri) )
2142 while ( (
' ' != http_version[0]) &&
2143 (http_version > uri) )
2145 if (http_version > uri)
2148 http_version[0] =
'\0';
2149 connection->
version = http_version + 1;
2150 uri_len = http_version - uri;
2155 uri_len = line_len - (uri - line);
2159 (
NULL != memchr (uri,
2191 &unused_num_headers);
2199 connection->
url = curi;
2234 "Application reported internal error, closing connection.\n"));
2274 size_t to_be_processed;
2275 size_t left_unprocessed;
2276 size_t processed_size;
2290 if ( (
'\r' == buffer_head[i]) ||
2291 (
'\n' == buffer_head[i]) )
2293 if ( (
'\r' == buffer_head[i]) ||
2294 (
'\n' == buffer_head[i]) )
2301 "Received malformed HTTP request (bad chunked encoding). Closing connection.\n"));
2312 uint64_t cur_chunk_left;
2318 if (cur_chunk_left > available)
2319 to_be_processed = available;
2322 to_be_processed = (size_t) cur_chunk_left;
2323 if (available > to_be_processed)
2335 while (i < available)
2337 if ( (
'\r' == buffer_head[i]) ||
2338 (
'\n' == buffer_head[i]) ||
2339 (
';' == buffer_head[i]) )
2347 if (
';' == buffer_head[i])
2349 while (i < available)
2351 if ( (
'\r' == buffer_head[i]) ||
2352 (
'\n' == buffer_head[i]) )
2360 if ( (i + 1 >= available) &&
2363 (
'0' == buffer_head[0]) ) )
2366 malformed = (end_size >= 16);
2372 current_chunk_size);
2373 malformed = (end_size != num_dig);
2380 "Received malformed HTTP request (bad chunked encoding). Closing connection.\n"));
2384 if ( (i < available) &&
2385 ( (
'\r' == buffer_head[i]) ||
2386 (
'\n' == buffer_head[i]) ) )
2418 to_be_processed = available;
2421 left_unprocessed = to_be_processed;
2436 "Application reported internal error, closing connection.\n"));
2439 if (left_unprocessed > to_be_processed)
2443 #ifdef HAVE_MESSAGES
2444 ,
_ (
"libmicrohttpd API violation")
2449 if (0 != left_unprocessed)
2452 #ifdef HAVE_MESSAGES 2460 "WARNING: incomplete upload processing and connection not suspended may result in hung connection.\n"));
2463 processed_size = to_be_processed - left_unprocessed;
2467 buffer_head += processed_size;
2468 available -= processed_size;
2472 while (
MHD_YES == instant_retry);
2473 if ( (available > 0) &&
2499 connection->
state = next_state;
2526 colon = strchr (line,
':');
2532 "Received malformed line (no colon). Closing connection.\n"));
2542 white = strchr (line,
' ');
2543 if ( (
NULL != white) &&
2546 white = strchr (line,
'\t');
2547 if ( (
NULL != white) &&
2554 while ( (
'\0' != colon[0]) &&
2555 ( (
' ' == colon[0]) ||
2556 (
'\t' == colon[0]) ) )
2563 connection->
last = line;
2564 connection->
colon = colon;
2589 last = connection->
last;
2590 if ( (
' ' == line[0]) ||
2595 last_len = strlen (last);
2598 while ( (
' ' == tmp[0]) ||
2601 tmp_len = strlen (tmp);
2614 last_len + tmp_len + 1);
2622 memcpy (&last[last_len],
2625 connection->
last = last;
2635 strlen (connection->
colon),
2693 #ifdef HAVE_MESSAGES 2694 MHD_DLOG (connection->
daemon,
2695 _ (
"Received HTTP 1.1 request without `Host' header.\n"));
2702 if (
NULL == response)
2707 "Closing connection (failed to create response)\n"));
2719 "Closing connection (failed to queue response)\n"));
2750 if ( (clen == end) ||
2754 #ifdef HAVE_MESSAGES 2755 MHD_DLOG (connection->
daemon,
2756 "Failed to parse `Content-Length' header. Closing connection.\n");
2791 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 2801 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 2821 #ifdef HTTPS_SUPPORT 2842 bytes_read = connection->
recv_cls (connection,
2857 "Socket disconnected while reading request.\n"));
2864 "Connection socket is closed due to error when reading request.\n"));
2868 if (0 == bytes_read)
2878 MHD_DLOG (connection->
daemon,
2879 _ (
"In function %s handling connection at state: %s\n"),
2881 MHD_state_to_string (connection->
state));
2883 switch (connection->
state)
2903 #ifdef UPGRADE_SUPPORT 2904 case MHD_CONNECTION_UPGRADE:
2934 #ifdef HTTPS_SUPPORT 2946 MHD_DLOG (connection->
daemon,
2947 _ (
"In function %s handling connection at state: %s\n"),
2949 MHD_state_to_string (connection->
state));
2951 switch (connection->
state)
2972 #ifdef HAVE_MESSAGES 2973 MHD_DLOG (connection->
daemon,
2974 _ (
"Failed to send data in request for %s.\n"),
2983 _ (
"Sent 100 continue response: `%.*s'\n"),
3026 "Connection was closed while sending response headers.\n"));
3054 uint64_t data_write_offset;
3056 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3065 #if defined(_MHD_HAVE_SENDFILE) 3066 if (MHD_resp_sender_sendfile == connection->resp_sender)
3068 ret = MHD_send_sendfile_ (connection);
3077 if (data_write_offset > (uint64_t)
SIZE_MAX)
3081 [(
size_t) data_write_offset],
3083 - (
size_t) data_write_offset,
3088 _ (
"Sent %d-byte DATA response: `%.*s'\n"),
3095 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3103 #ifdef HAVE_MESSAGES 3104 MHD_DLOG (connection->
daemon,
3105 _ (
"Failed to send data in request for `%s'.\n"),
3135 "Connection was closed while sending response body.\n"));
3165 "Connection was closed while sending response body.\n"));
3180 #ifdef UPGRADE_SUPPORT 3181 case MHD_CONNECTION_UPGRADE:
3188 _ (
"Internal error\n"));
3216 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3248 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3256 if ( (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
3257 (! MHD_itc_activate_ (daemon->
itc,
"c")) )
3259 #ifdef HAVE_MESSAGES 3262 "Failed to signal end of connection via inter-thread communication channel"));
3290 #ifdef HTTPS_SUPPORT 3293 if ((MHD_TLS_CONN_INIT <= connection->tls_state) &&
3300 _ (
"In function %s handling connection at state: %s\n"),
3302 MHD_state_to_string (connection->
state));
3304 switch (connection->
state)
3313 if ( (
NULL == line) ||
3527 "Closing connection (failed to create response header)\n"));
3537 #ifdef UPGRADE_SUPPORT 3540 connection->
state = MHD_CONNECTION_UPGRADE;
3571 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3577 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3586 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3602 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3610 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3619 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3636 "Closing connection (failed to create response header)\n"));
3722 #ifdef UPGRADE_SUPPORT 3723 case MHD_CONNECTION_UPGRADE:
3737 if ( (0 != timeout) &&
3749 #ifdef EPOLL_SUPPORT 3753 ret = MHD_connection_epoll_update_ (connection);
3761 #ifdef EPOLL_SUPPORT 3784 struct epoll_event event;
3786 event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET;
3787 event.data.ptr = connection;
3788 if (0 != epoll_ctl (daemon->epoll_fd,
3793 #ifdef HAVE_MESSAGES 3796 _ (
"Call to epoll_ctl failed: %s\n"),
3840 #ifdef HTTPS_SUPPORT 3842 if (
NULL == connection->tls_session)
3844 connection->cipher = gnutls_cipher_get (connection->tls_session);
3847 if (
NULL == connection->tls_session)
3849 connection->protocol = gnutls_protocol_get_version (
3850 connection->tls_session);
3853 if (
NULL == connection->tls_session)
3872 connection_timeout_dummy;
3901 daemon = connection->
daemon;
3907 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3922 va_start (ap, option);
3938 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3961 unsigned int status_code,
3966 if ( (
NULL == connection) ||
3967 (
NULL == response) ||
3972 daemon = connection->
daemon;
3978 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3981 (! MHD_thread_ID_match_current_ (connection->
pid.ID)) )
3983 #ifdef HAVE_MESSAGES 3985 _ (
"Attempted to queue response on wrong thread!\n"));
3990 #ifdef UPGRADE_SUPPORT 3991 if ( (
NULL != response->upgrade_handler) &&
3994 #ifdef HAVE_MESSAGES 3997 "Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n"));
4002 (
NULL != response->upgrade_handler) )
4004 #ifdef HAVE_MESSAGES 4007 "Application used invalid status code for 'upgrade' response!\n"));
4015 #if defined(_MHD_HAVE_SENDFILE) 4016 if ( (response->
fd == -1) ||
4018 connection->resp_sender = MHD_resp_sender_std;
4020 connection->resp_sender = MHD_resp_sender_sendfile;
static int process_header_line(struct MHD_Connection *connection, char *line)
static ssize_t send_param_adapter(struct MHD_Connection *connection, const void *other, size_t i)
#define MHD_send_(s, b, l)
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
_MHD_EXTERN int MHD_get_connection_values_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls)
static int parse_cookie_header(struct MHD_Connection *connection)
void * unescape_callback_cls
static int 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 MHD_connection_handle_write(struct MHD_Connection *connection)
Header for platform missing functions.
static int try_ready_normal_body(struct MHD_Connection *connection)
uint64_t current_chunk_offset
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
#define MHD_HTTP_METHOD_CONNECT
static void MHD_connection_update_event_loop_info(struct MHD_Connection *connection)
struct sockaddr_storage addr
struct MHD_Connection * cleanup_head
enum MHD_CONNECTION_STATE state
static int try_ready_chunked_body(struct MHD_Connection *connection)
#define MHD_lookup_header_s_token_ci(c, h, tkn)
uint64_t response_write_position
enum MHD_ConnKeepAlive keepalive
size_t MHD_str_to_uint64_(const char *str, uint64_t *out_val)
#define HTTP_100_CONTINUE
enum MHD_ConnectionEventLoopInfo event_loop_info
#define MHD_mutex_unlock_chk_(pmutex)
size_t MHD_pool_get_free(struct MemoryPool *pool)
time_t connection_timeout
Methods for managing connections.
MHD_PanicCallback mhd_panic
#define MHD_socket_get_error_()
internal monotonic clock functions implementations
void MHD_connection_close_(struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code)
struct MHD_Response * response
#define REQUEST_LACKS_HOST
#define MHD_SENFILE_CHUNK_
int 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)
#define MHD_HTTP_NOT_MODIFIED
bool MHD_str_has_token_caseless_(const char *str, const char *const token, size_t token_len)
bool MHD_parse_arguments_(struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
struct MHD_Connection * manual_timeout_head
void MHD_connection_mark_closed_(struct MHD_Connection *connection)
MHD_RequestTerminationCode
MHD_thread_handle_ID_ pid
int MHD_str_equal_caseless_(const char *str1, const char *str2)
time_t MHD_monotonic_sec_counter(void)
static void transmit_error_response(struct MHD_Connection *connection, unsigned int status_code, const char *message)
MHD_AccessHandlerCallback default_handler
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
static void call_connection_handler(struct MHD_Connection *connection)
uint64_t remaining_upload_size
unsigned int responseCode
#define MHD_ERR_CONNRESET_
ssize_t MHD_send_on_connection2_(struct MHD_Connection *connection, const char *header, size_t header_size, const char *buffer, size_t buffer_size)
Methods for managing response objects.
static void cleanup_connection(struct MHD_Connection *connection)
void MHD_update_last_activity_(struct MHD_Connection *connection)
#define MHD_UNSIGNED_LONG_LONG
void * uri_log_callback_cls
static ssize_t recv_param_adapter(struct MHD_Connection *connection, void *other, size_t i)
struct MHD_Daemon * daemon
int MHD_response_execute_upgrade_(struct MHD_Response *response, struct MHD_Connection *connection)
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_check_response_header_s_token_ci(r, k, tkn)
#define MHD_SENFILE_CHUNK_THR_P_C_
Header for platform-independent inter-thread communication.
static void connection_close_error(struct MHD_Connection *connection, const char *emsg)
void * MHD_pool_reset(struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size)
_MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
static int keepalive_possible(struct MHD_Connection *connection)
#define DLL_insert(head, tail, element)
void MHD_increment_response_rc(struct MHD_Response *response)
#define MHD_HTTP_URI_TOO_LONG
struct MHD_HTTP_Header * first_header
#define MHD_socket_last_strerr_()
size_t write_buffer_send_offset
struct MHD_Connection * connections_tail
void * MHD_pool_allocate(struct MemoryPool *pool, size_t size, int from_end)
static int 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)
size_t continue_message_write_offset
#define REQUEST_MALFORMED
#define MHD_INVALID_SOCKET
size_t MHD_strx_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
internal shared structures
enum MHD_HTTP_StatusCode status_code
#define MHD_SCKT_SEND_MAX_SIZE_
void * MHD_pool_reallocate(struct MemoryPool *pool, void *old, size_t old_size, size_t new_size)
struct MHD_Connection * connections_head
#define MHD_HTTP_NO_CONTENT
LogCallback uri_log_callback
void MHD_connection_handle_read(struct MHD_Connection *connection)
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
time_t connection_timeout
_MHD_EXTERN int MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
#define MHD_SCKT_ERR_IS_(err, code)
Methods for managing connections.
ssize_t MHD_send_on_connection_(struct MHD_Connection *connection, const char *buffer, size_t buffer_size, enum MHD_SendSocketOptions options)
#define MHD_CONTENT_READER_END_OF_STREAM
#define EDLL_remove(head, tail, element)
struct MHD_Connection * manual_timeout_tail
static void get_date_string(char *date, size_t date_len)
Header for string manipulating helpers.
Implementation of send() wrappers.
#define DLL_remove(head, tail, element)
static int need_100_continue(struct MHD_Connection *connection)
#define MHD_STATICSTR_LEN_(macro)
#define MHD_HTTP_VERSION_1_1
struct MHD_Connection * normal_timeout_head
void MHD_pool_destroy(struct MemoryPool *pool)
#define MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
UnescapeCallback unescape_callback
_MHD_EXTERN int MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
void MHD_connection_finish_forward_(struct MHD_Connection *connection) MHD_NONNULL(1)
#define XDLL_remove(head, tail, element)
unsigned int connection_timeout_dummy
#define MHD_HTTP_BAD_REQUEST
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
struct MHD_Connection * suspended_connections_tail
static int check_write_done(struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state)
bool MHD_run_tls_handshake_(struct MHD_Connection *connection)
struct MHD_Connection * cleanup_tail
int MHD_connection_handle_idle(struct MHD_Connection *connection)
static int process_broken_line(struct MHD_Connection *connection, char *line, enum MHD_ValueKind kind)
enum MHD_ResponseFlags flags
#define MHD_recv_(s, b, l)
#define MHD_HTTP_METHOD_HEAD
static void parse_connection_headers(struct MHD_Connection *connection)
size_t write_buffer_append_offset
struct MHD_Connection * normal_timeout_tail
MHD_RequestCompletedCallback notify_completed
#define MHD_mutex_lock_chk_(pmutex)
void MHD_set_http_callbacks_(struct MHD_Connection *connection)
#define MHD_HTTP_METHOD_PUT
void * notify_completed_cls
static void process_request_body(struct MHD_Connection *connection)
#define MHD_HTTP_VERSION_1_0
TransmitCallback send_cls
_MHD_EXTERN int MHD_get_connection_values(struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
#define MHD_HTTP_INTERNAL_SERVER_ERROR
#define MHD_CONTENT_READER_END_WITH_ERROR
MHD_ContentReaderCallback crc
static int parse_initial_message_line(struct MHD_Connection *connection, char *line, size_t line_len)
#define XDLL_insert(head, tail, element)
#define MHD_UNSIGNED_LONG_LONG_PRINTF
#define MHD_HTTP_PROCESSING
#define MHD_SCKT_ECONNRESET_
_MHD_EXTERN int 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 * suspended_connections_head
size_t read_buffer_offset
static char * get_next_header_line(struct MHD_Connection *connection, size_t *line_len)
void * default_handler_cls
_MHD_EXTERN const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
#define MHD_SCKT_ERR_IS_EINTR_(err)
MHD_mutex_ cleanup_connection_mutex
#define CONNECTION_CLOSE_ERROR(c, emsg)
uint64_t current_chunk_size
struct MHD_HTTP_Header * headers_received
#define MHD_HTTP_SWITCHING_PROTOCOLS
limits values definitions
_MHD_EXTERN const char * MHD_get_reason_phrase_for(unsigned int code)
bool MHD_tls_connection_shutdown(struct MHD_Connection *connection)
_MHD_EXTERN int MHD_set_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value)
struct MHD_HTTP_Header * headers_received_tail
static int build_header_response(struct MHD_Connection *connection)
#define MHD_HTTP_METHOD_POST
bool MHD_str_equal_caseless_bin_n_(const char *const str1, const char *const str2, size_t len)
int(* MHD_KeyValueIteratorN)(void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size)