47 #define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" 57 #define REQUEST_TOO_BIG "<html><head><title>Request too big</title></head><body>Your HTTP header was too big for the memory constraints of this webserver.</body></html>" 59 #define REQUEST_TOO_BIG "" 70 #define REQUEST_LACKS_HOST "<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>" 72 #define REQUEST_LACKS_HOST "" 83 #define REQUEST_MALFORMED "<html><head><title>Request malformed</title></head><body>Your HTTP request was syntactically incorrect.</body></html>" 85 #define REQUEST_MALFORMED "" 95 #define INTERNAL_ERROR "<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>" 97 #define INTERNAL_ERROR "" 104 #define DEBUG_CLOSE MHD_NO 109 #define DEBUG_SEND_DATA MHD_NO 134 #if defined(TCP_CORK) || defined(TCP_PUSH) 153 #if defined(TCP_CORK) || defined(TCP_NOPUSH) 155 #if defined(TCP_NODELAY) 160 #if defined(TCP_NOPUSH) && !defined(TCP_CORK) 162 res = (0 == setsockopt (connection->
socket_fd,
165 (
const void *) &on_val,
168 #if defined(TCP_NODELAY) 171 res &= (0 == setsockopt (connection->
socket_fd,
174 (
const void *) &off_val,
179 #if defined(TCP_NODELAY) 183 (void) setsockopt (connection->
socket_fd,
186 (
const void *) &off_val,
190 res = (0 == setsockopt (connection->
socket_fd,
193 (
const void *) &on_val,
211 #if defined(TCP_NODELAY) 214 #if defined(TCP_CORK) || defined(TCP_NOPUSH) 218 if (
NULL == connection)
220 #if defined(TCP_CORK) 222 res &= (0 == setsockopt (connection->
socket_fd,
225 (
const void *) &off_val,
229 #if defined(TCP_NODELAY) 231 res &= (0 == setsockopt (connection->
socket_fd,
234 (
const void *) &on_val,
238 #if defined(TCP_NOPUSH) && !defined(TCP_CORK) 240 res &= (0 == setsockopt (connection->
socket_fd,
243 (
const void *) &off_val,
265 #if defined(TCP_NOPUSH) && !defined(TCP_CORK) 269 if (
NULL == connection)
272 #if defined(TCP_NOPUSH) && !defined(TCP_CORK) 294 #if defined(TCP_NODELAY) 297 #if defined(TCP_CORK) 299 socklen_t param_size =
sizeof (cork_val);
303 #if defined(TCP_CORK) 307 if ( (0 != getsockopt (connection->
socket_fd,
313 res &= (0 == setsockopt (connection->
socket_fd,
316 (
const void *) &off_val,
319 #elif defined(TCP_NOPUSH) 323 res &= (0 == setsockopt (connection->
socket_fd,
326 (
const void *) &off_val,
331 res &= (0 == setsockopt (connection->
socket_fd,
334 (
const void *) &off_val,
364 if (
NULL == connection)
368 if (0 != (pos->
kind & kind))
371 if ( (
NULL != iterator) &&
372 (
MHD_YES != iterator (iterator_cls,
420 pos->
header = (
char *) key;
421 pos->
value = (
char *) value;
456 if (
NULL == connection)
459 if ((0 != (pos->
kind & kind)) &&
491 if (
NULL == connection ||
NULL == header || 0 == header[0] ||
NULL == token || 0 == token[0])
496 ( (header == pos->
header) ||
517 #define MHD_lookup_header_s_token_ci(c,h,tkn) \ 518 MHD_lookup_header_token_ci((c),(h),(tkn),MHD_STATICSTR_LEN_(tkn)) 614 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 629 struct MHD_UpgradeResponseHandle *urh = connection->urh;
640 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
645 MHD_PANIC (
_(
"Failed to remove FD from epoll set\n"));
647 if (urh->in_eready_list)
650 daemon->eready_urh_tail,
652 urh->in_eready_list =
false;
659 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
664 MHD_PANIC (
_(
"Failed to remove FD from epoll set\n"));
669 shutdown (urh->mhd.socket, SHUT_RDWR);
693 MHD_DLOG (connection->
daemon,
706 #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, emsg) 708 #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, NULL) 742 if (MHD_resp_sender_sendfile == connection->resp_sender)
761 if ( ((ssize_t)MHD_CONTENT_READER_END_OF_STREAM) == ret)
766 _(
"Closing connection (application reported error generating data)\n"));
804 2 * (0xFFFFFF +
sizeof(cbuf) + 2));
812 _(
"Closing connection (out of memory)\n"));
833 const size_t data_write_offset
836 ret = response->
data_size - data_write_offset;
840 &response->
data[data_write_offset],
856 _(
"Closing connection (application error generating response)\n"));
877 cblen = MHD_snprintf_(cbuf,
883 memcpy (&connection->
write_buffer[sizeof (cbuf) - cblen],
920 (0 != (connection->
response->
flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) )
930 #ifdef UPGRADE_SUPPORT 968 static const char *
const days[] = {
969 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat" 971 static const char *
const mons[] = {
972 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
973 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" 977 #if !defined(HAVE_C11_GMTIME_S) && !defined(HAVE_W32_GMTIME_S) && !defined(HAVE_GMTIME_R) 983 #if defined(HAVE_C11_GMTIME_S) 984 if (
NULL == gmtime_s (&t,
987 #elif defined(HAVE_W32_GMTIME_S) 988 if (0 != gmtime_s (&now,
991 #elif defined(HAVE_GMTIME_R) 992 if (
NULL == gmtime_r(&t,
1001 MHD_snprintf_ (date,
1003 "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
1004 days[now.tm_wday % 7],
1005 (
unsigned int) now.tm_mday,
1006 mons[now.tm_mon % 12],
1007 (
unsigned int) (1900 + now.tm_year),
1008 (
unsigned int) now.tm_hour,
1009 (
unsigned int) now.tm_min,
1010 (
unsigned int) now.tm_sec);
1064 char content_length_buf[128];
1065 size_t content_length_len;
1068 const char *reason_phrase;
1070 bool client_requested_close;
1071 bool response_has_close;
1072 bool response_has_keepalive;
1073 const char *have_encoding;
1074 const char *have_content_length;
1076 int must_add_chunked_encoding;
1077 int must_add_keep_alive;
1078 int must_add_content_length;
1081 if (0 == connection->
version[0])
1096 MHD_snprintf_ (code,
1107 off = strlen (code);
1118 size += strlen (date);
1131 must_add_chunked_encoding =
MHD_NO;
1132 must_add_keep_alive =
MHD_NO;
1133 must_add_content_length =
MHD_NO;
1134 response_has_close =
false;
1135 response_has_keepalive =
false;
1136 switch (connection->
state)
1149 if (0 != (connection->
response->
flags & MHD_RF_HTTP_VERSION_1_0_ONLY))
1151 #ifdef UPGRADE_SUPPORT 1152 else if (
NULL != connection->
response->upgrade_handler)
1161 #ifdef UPGRADE_SUPPORT
1164 (! response_has_close) &&
1165 (! client_requested_close) )
1178 if (
NULL == have_encoding)
1180 must_add_chunked_encoding =
MHD_YES;
1198 if (! response_has_close)
1204 if ( ( (client_requested_close) ||
1207 (! response_has_close) &&
1208 #ifdef UPGRADE_SUPPORT
1211 (0 == (connection->
response->
flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) )
1225 (
NULL == have_content_length) &&
1246 = MHD_snprintf_ (content_length_buf,
1247 sizeof (content_length_buf),
1250 must_add_content_length =
MHD_YES;
1254 if ( (! response_has_keepalive) &&
1255 (! response_has_close) &&
1256 (
MHD_NO == must_add_close) &&
1258 #ifdef UPGRADE_SUPPORT
1262 must_add_keep_alive =
MHD_YES;
1265 response_has_keepalive =
false;
1273 if ( (must_add_close) || (response_has_close) )
1275 else if ( (must_add_keep_alive) || (response_has_keepalive) )
1281 if (must_add_keep_alive)
1283 if (must_add_chunked_encoding)
1285 if (must_add_content_length)
1286 size += content_length_len;
1287 EXTRA_CHECK (! (must_add_close && must_add_keep_alive) );
1288 EXTRA_CHECK (! (must_add_chunked_encoding && must_add_content_length) );
1293 if ( (pos->
kind == kind) &&
1294 (! ( (
MHD_YES == must_add_close) &&
1295 (response_has_keepalive) &&
1299 "Keep-Alive")) ) ) )
1300 size += strlen (pos->
header) + strlen (pos->
value) + 4;
1308 #ifdef HAVE_MESSAGES 1309 MHD_DLOG (connection->
daemon,
1310 "Not enough memory for write!\n");
1324 "Connection: close\r\n",
1328 if (must_add_keep_alive)
1332 "Connection: Keep-Alive\r\n",
1336 if (must_add_chunked_encoding)
1340 "Transfer-Encoding: chunked\r\n",
1344 if (must_add_content_length)
1349 content_length_len);
1350 off += content_length_len;
1355 if ( (pos->
kind == kind) &&
1356 (! ( (
MHD_YES == must_add_close) &&
1357 (response_has_keepalive) &&
1361 "Keep-Alive")) ) ) )
1362 off += MHD_snprintf_ (&data[off],
1372 off += strlen (date);
1403 unsigned int status_code,
1404 const char *message)
1416 #ifdef HAVE_MESSAGES 1417 MHD_DLOG (connection->
daemon,
1418 _(
"Error processing request (HTTP response code is %u (`%s')). Closing connection.\n"),
1429 MHD_RESPMEM_PERSISTENT);
1441 _(
"Closing connection (failed to create response header)\n"));
1467 MHD_DLOG (connection->
daemon,
1468 _(
"In function %s handling connection at state: %s\n"),
1470 MHD_state_to_string (connection->
state));
1472 switch (connection->
state)
1474 #ifdef HTTPS_SUPPORT 1476 if (0 == gnutls_record_get_direction (connection->tls_session))
1592 #ifdef UPGRADE_SUPPORT 1593 case MHD_CONNECTION_UPGRADE:
1629 while ( (pos < connection->read_buffer_offset - 1) &&
1630 (
'\r' != rbuf[pos]) &&
1631 (
'\n' != rbuf[pos]) )
1634 (
'\n' != rbuf[pos]) )
1655 if ( (
'\r' == rbuf[pos]) &&
1656 (
'\n' == rbuf[pos + 1]) )
1689 #ifdef HAVE_MESSAGES 1690 MHD_DLOG (connection->
daemon,
1691 _(
"Not enough memory in pool to allocate header record!\n"));
1731 #ifdef HAVE_MESSAGES 1732 MHD_DLOG (connection->
daemon,
1733 _(
"Not enough memory in pool to parse cookies!\n"));
1750 while ( ((*sce) !=
'\0') &&
1757 while ( (*ekill ==
' ') &&
1779 while ( (
'\0' != semicolon[0]) &&
1781 ( (
';' != semicolon[0]) &&
1782 (
',' != semicolon[0]) ) ) )
1784 if (
'"' == semicolon[0])
1785 quotes = (quotes + 1) & 1;
1788 if (
'\0' == semicolon[0])
1790 if (
NULL != semicolon)
1792 semicolon[0] =
'\0';
1796 if ( (
'"' == equals[0]) &&
1797 (
'"' == equals[strlen (equals) - 1]) )
1799 equals[strlen (equals) - 1] =
'\0';
1832 unsigned int unused_num_headers;
1834 if (
NULL == (uri = memchr (line,
1839 connection->
method = line;
1843 while ( (
' ' == uri[0]) &&
1844 ( (
size_t)(uri - line) < line_len) )
1846 if ((
size_t)(uri - line) == line_len)
1857 http_version = line + line_len - 1;
1859 while ( (
' ' == http_version[0]) &&
1860 (http_version > uri) )
1863 while ( (
' ' != http_version[0]) &&
1864 (http_version > uri) )
1866 if (http_version > uri)
1868 http_version[0] =
'\0';
1869 connection->
version = http_version + 1;
1872 http_version - uri);
1879 line_len - (uri - line));
1899 &unused_num_headers);
1905 connection->
url = curi;
1938 _(
"Application reported internal error, closing connection.\n"));
1966 size_t to_be_processed;
1967 size_t left_unprocessed;
1968 size_t processed_size;
1981 if ( (
'\r' == buffer_head[i]) ||
1982 (
'\n' == buffer_head[i]) )
1984 if ( (
'\r' == buffer_head[i]) ||
1985 (
'\n' == buffer_head[i]) )
1991 _(
"Received malformed HTTP request (bad chunked encoding). Closing connection.\n"));
2002 uint64_t cur_chunk_left;
2008 if (cur_chunk_left > available)
2009 to_be_processed = available;
2012 to_be_processed = (size_t)cur_chunk_left;
2013 if (available > to_be_processed)
2025 while (i < available)
2027 if ( (
'\r' == buffer_head[i]) ||
2028 (
'\n' == buffer_head[i]) ||
2029 (
';' == buffer_head[i]) )
2037 if (
';' == buffer_head[i])
2039 while (i < available)
2041 if ( (
'\r' == buffer_head[i]) ||
2042 (
'\n' == buffer_head[i]) )
2050 if ( (i + 1 >= available) &&
2053 (
'0' == buffer_head[0]) ) )
2056 malformed = (end_size >= 16);
2062 malformed = (end_size != num_dig);
2068 _(
"Received malformed HTTP request (bad chunked encoding). Closing connection.\n"));
2072 if ( (i < available) &&
2073 ( (
'\r' == buffer_head[i]) ||
2074 (
'\n' == buffer_head[i]) ) )
2106 to_be_processed = available;
2109 left_unprocessed = to_be_processed;
2123 _(
"Application reported internal error, closing connection.\n"));
2126 if (left_unprocessed > to_be_processed)
2130 #ifdef HAVE_MESSAGES
2131 ,
_(
"libmicrohttpd API violation")
2136 if (0 != left_unprocessed)
2139 #ifdef HAVE_MESSAGES 2145 MHD_DLOG (connection->
daemon,
2146 _(
"WARNING: incomplete upload processing and connection not suspended may result in hung connection.\n"));
2149 processed_size = to_be_processed - left_unprocessed;
2153 buffer_head += processed_size;
2154 available -= processed_size;
2158 while (
MHD_YES == instant_retry);
2183 bytes_read = connection->
recv_cls (connection,
2204 if (0 == bytes_read)
2233 ret = connection->
send_cls (connection,
2250 _(
"Sent response: `%.*s'\n"),
2279 connection->
state = next_state;
2306 colon = strchr (line,
':');
2311 _(
"Received malformed line (no colon). Closing connection.\n"));
2321 white = strchr (line,
' ');
2322 if ( (
NULL != white) &&
2325 white = strchr (line,
'\t');
2326 if ( (
NULL != white) &&
2333 while ( (
'\0' != colon[0]) &&
2334 ( (
' ' == colon[0]) ||
2335 (
'\t' == colon[0]) ) )
2342 connection->
last = line;
2343 connection->
colon = colon;
2368 last = connection->
last;
2369 if ( (
' ' == line[0]) ||
2374 last_len = strlen (last);
2377 while ( (
' ' == tmp[0]) ||
2380 tmp_len = strlen (tmp);
2393 last_len + tmp_len + 1);
2401 memcpy (&last[last_len], tmp, tmp_len + 1);
2402 connection->
last = last;
2461 #ifdef HAVE_MESSAGES 2462 MHD_DLOG (connection->
daemon,
2463 _(
"Received HTTP 1.1 request without `Host' header.\n"));
2469 MHD_RESPMEM_PERSISTENT);
2497 if ( (clen == end) ||
2501 #ifdef HAVE_MESSAGES 2502 MHD_DLOG (connection->
daemon,
2503 "Failed to parse `Content-Length' header. Closing connection.\n");
2576 MHD_DLOG (connection->
daemon,
2577 _(
"In function %s handling connection at state: %s\n"),
2579 MHD_state_to_string (connection->
state));
2581 switch (connection->
state)
2602 #ifdef UPGRADE_SUPPORT 2603 case MHD_CONNECTION_UPGRADE:
2640 MHD_DLOG (connection->
daemon,
2641 _(
"In function %s handling connection at state: %s\n"),
2643 MHD_state_to_string (connection->
state));
2645 switch (connection->
state)
2656 ret = connection->
send_cls (connection,
2668 #ifdef HAVE_MESSAGES 2669 MHD_DLOG (connection->
daemon,
2670 _(
"Failed to send data in request for %s: %s\n"),
2680 _(
"Sent 100 continue response: `%.*s'\n"),
2709 uint64_t data_write_offset;
2720 if (data_write_offset > (uint64_t)
SIZE_MAX)
2722 ret = connection->
send_cls (connection,
2724 [(
size_t)data_write_offset],
2726 (
size_t)data_write_offset);
2730 _(
"Sent %d-byte DATA response: `%.*s'\n"),
2744 #ifdef HAVE_MESSAGES 2745 MHD_DLOG (connection->
daemon,
2746 _(
"Failed to send data in request for `%s': %s\n"),
2798 #ifdef UPGRADE_SUPPORT 2799 case MHD_CONNECTION_UPGRADE:
2806 _(
"Internal error\n"));
2872 if ( (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
2873 (! MHD_itc_activate_ (daemon->
itc,
"c")) )
2875 #ifdef HAVE_MESSAGES 2877 _(
"Failed to signal end of connection via inter-thread communication channel"));
2907 _(
"In function %s handling connection at state: %s\n"),
2909 MHD_state_to_string (connection->
state));
2911 switch (connection->
state)
2920 if ( (
NULL == line) ||
3142 _(
"Closing connection (failed to create response header)\n"));
3160 #ifdef UPGRADE_SUPPORT 3164 connection->
state = MHD_CONNECTION_UPGRADE;
3254 _(
"Closing connection (failed to create response header)\n"));
3346 #ifdef UPGRADE_SUPPORT 3347 case MHD_CONNECTION_UPGRADE:
3361 if ( (0 != timeout) &&
3372 #ifdef EPOLL_SUPPORT 3376 ret = MHD_connection_epoll_update_ (connection);
3384 #ifdef EPOLL_SUPPORT 3407 struct epoll_event event;
3409 event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET;
3410 event.data.ptr = connection;
3411 if (0 != epoll_ctl (daemon->epoll_fd,
3416 #ifdef HAVE_MESSAGES 3419 _(
"Call to epoll_ctl failed: %s\n"),
3464 #ifdef HTTPS_SUPPORT 3466 if (
NULL == connection->tls_session)
3468 connection->cipher = gnutls_cipher_get (connection->tls_session);
3471 if (
NULL == connection->tls_session)
3473 connection->protocol = gnutls_protocol_get_version (connection->tls_session);
3476 if (
NULL == connection->tls_session)
3517 enum MHD_CONNECTION_OPTION option,
3523 daemon = connection->
daemon;
3526 case MHD_CONNECTION_OPTION_TIMEOUT:
3543 va_start (ap, option);
3580 unsigned int status_code,
3583 #ifdef UPGRADE_SUPPORT 3587 if ( (
NULL == connection) ||
3588 (
NULL == response) ||
3593 #ifdef UPGRADE_SUPPORT 3594 daemon = connection->
daemon;
3595 if ( (
NULL != response->upgrade_handler) &&
3598 #ifdef HAVE_MESSAGES 3600 _(
"Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n"));
3605 (
NULL != response->upgrade_handler) )
3607 #ifdef HAVE_MESSAGES 3609 _(
"Application used invalid status code for 'upgrade' response!\n"));
3618 if ( (response->
fd == -1) ||
3620 connection->resp_sender = MHD_resp_sender_std;
3622 connection->resp_sender = MHD_resp_sender_sendfile;
static int process_header_line(struct MHD_Connection *connection, char *line)
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
static int parse_cookie_header(struct MHD_Connection *connection)
void * unescape_callback_cls
#define MHD_send_(s, b, l)
static int try_ready_normal_body(struct MHD_Connection *connection)
uint64_t current_chunk_offset
#define DLL_insert(head, tail, element)
#define MHD_HTTP_METHOD_CONNECT
static void MHD_connection_update_event_loop_info(struct MHD_Connection *connection)
enum MHD_CONNECTION_STATE state
static int try_ready_chunked_body(struct MHD_Connection *connection)
void * MHD_pool_reset(struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size)
#define MHD_lookup_header_s_token_ci(c, h, tkn)
uint64_t response_write_position
enum MHD_ConnKeepAlive keepalive
void MHD_pool_destroy(struct MemoryPool *pool)
#define HTTP_100_CONTINUE
enum MHD_ConnectionEventLoopInfo event_loop_info
int MHD_connection_handle_write(struct MHD_Connection *connection)
time_t connection_timeout
static int connection_add_header(struct MHD_Connection *connection, const char *key, const char *value, enum MHD_ValueKind kind)
Methods for managing connections.
void MHD_connection_close_(struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code)
const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
struct MHD_Response * response
#define REQUEST_LACKS_HOST
#define MHD_socket_get_error_()
struct MHD_Connection * normal_timeout_tail
Header for platform missing functions.
#define MHD_HTTP_NOT_MODIFIED
void MHD_connection_mark_closed_(struct MHD_Connection *connection)
MHD_RequestTerminationCode
static int do_read(struct MHD_Connection *connection)
struct MHD_HTTP_Header * first_header
static void transmit_error_response(struct MHD_Connection *connection, unsigned int status_code, const char *message)
MHD_AccessHandlerCallback default_handler
void * MHD_pool_allocate(struct MemoryPool *pool, size_t size, int from_end)
static void call_connection_handler(struct MHD_Connection *connection)
uint64_t remaining_upload_size
unsigned int responseCode
int MHD_parse_arguments_(struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers)
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
int MHD_response_execute_upgrade_(struct MHD_Response *response, struct MHD_Connection *connection)
struct MHD_Daemon * daemon
int(* idle_handler)(struct MHD_Connection *connection)
struct MHD_Connection * manual_timeout_head
struct MHD_Connection * cleanup_head
static bool MHD_lookup_header_token_ci(const struct MHD_Connection *connection, const char *header, const char *token, size_t token_len)
#define MHD_SCKT_ERR_IS_REMOTE_DISCNN_(err)
static void connection_close_error(struct MHD_Connection *connection, const char *emsg)
#define XDLL_remove(head, tail, element)
#define MHD_mutex_unlock_chk_(pmutex)
#define XDLL_insert(head, tail, element)
static int keepalive_possible(struct MHD_Connection *connection)
#define MHD_HTTP_URI_TOO_LONG
struct MHD_Connection * cleanup_tail
Header for platform-independent inter-thread communication.
int MHD_connection_handle_read(struct MHD_Connection *connection)
#define MHD_STATICSTR_LEN_(macro)
size_t write_buffer_send_offset
void * MHD_pool_reallocate(struct MemoryPool *pool, void *old, size_t old_size, size_t new_size)
struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
struct MHD_Connection * manual_timeout_tail
size_t continue_message_write_offset
#define REQUEST_MALFORMED
#define MHD_INVALID_SOCKET
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
#define MHD_HTTP_NO_CONTENT
LogCallback uri_log_callback
static int socket_start_no_buffering(struct MHD_Connection *connection)
void MHD_destroy_response(struct MHD_Response *response)
time_t connection_timeout
int MHD_set_connection_option(struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
void MHD_increment_response_rc(struct MHD_Response *response)
Methods for managing connections.
#define MHD_CONTENT_READER_END_OF_STREAM
int(* read_handler)(struct MHD_Connection *connection)
struct MHD_Connection * normal_timeout_head
static void get_date_string(char *date, size_t date_len)
const union MHD_ConnectionInfo * MHD_get_connection_info(struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
static int need_100_continue(struct MHD_Connection *connection)
limits values definitions
#define MHD_HTTP_VERSION_1_1
internal shared structures
#define MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
UnescapeCallback unescape_callback
int MHD_tls_connection_shutdown(struct MHD_Connection *connection)
#define MHD_socket_last_strerr_()
static int try_grow_read_buffer(struct MHD_Connection *connection)
int MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
internal monotonic clock functions implementations
int(* write_handler)(struct MHD_Connection *connection)
unsigned int connection_timeout_dummy
#define MHD_HTTP_BAD_REQUEST
struct MHD_Connection * connections_head
static int check_write_done(struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state)
int MHD_connection_handle_idle(struct MHD_Connection *connection)
#define MHD_socket_strerr_(err)
static int process_broken_line(struct MHD_Connection *connection, char *line, enum MHD_ValueKind kind)
#define MHD_check_response_header_s_token_ci(r, k, tkn)
enum MHD_ResponseFlags flags
#define MHD_connection_finish_forward_(conn)
#define MHD_HTTP_METHOD_HEAD
static void parse_connection_headers(struct MHD_Connection *connection)
time_t MHD_monotonic_sec_counter(void)
Header for string manipulating helpers.
size_t write_buffer_append_offset
MHD_RequestCompletedCallback notify_completed
bool MHD_str_has_token_caseless_(const char *str, const char *const token, size_t token_len)
static int socket_start_extra_buffering(struct MHD_Connection *connection)
void MHD_set_http_callbacks_(struct MHD_Connection *connection)
#define MHD_HTTP_METHOD_PUT
int MHD_str_equal_caseless_(const char *str1, const char *str2)
#define DLL_remove(head, tail, element)
void * notify_completed_cls
static void process_request_body(struct MHD_Connection *connection)
#define MHD_HTTP_VERSION_1_0
TransmitCallback send_cls
#define EDLL_remove(head, tail, element)
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)
MHD_PanicCallback mhd_panic
struct MHD_Connection * suspended_connections_tail
static int socket_start_normal_buffering(struct MHD_Connection *connection)
#define MHD_UNSIGNED_LONG_LONG_PRINTF
#define MHD_HTTP_PROCESSING
static int socket_flush_possible(struct MHD_Connection *connection)
static int socket_start_no_buffering_flush(struct MHD_Connection *connection)
static int do_write(struct MHD_Connection *connection)
size_t read_buffer_offset
static char * get_next_header_line(struct MHD_Connection *connection, size_t *line_len)
void * default_handler_cls
size_t MHD_strx_to_uint64_n_(const char *str, size_t maxlen, uint64_t *out_val)
#define MHD_SCKT_ERR_IS_EINTR_(err)
MHD_mutex_ cleanup_connection_mutex
#define CONNECTION_CLOSE_ERROR(c, emsg)
uint64_t current_chunk_size
Header for platform-independent locks abstraction.
struct MHD_HTTP_Header * headers_received
#define MHD_HTTP_SWITCHING_PROTOCOLS
struct MHD_Connection * connections_tail
_MHD_EXTERN const char * MHD_get_reason_phrase_for(unsigned int code)
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_mutex_lock_chk_(pmutex)
#define MHD_HTTP_METHOD_POST
size_t MHD_str_to_uint64_(const char *str, uint64_t *out_val)
struct MHD_Connection * suspended_connections_head
memory pool; mostly used for efficient (de)allocation for each connection and bounding memory use for...