GNU libmicrohttpd 1.0.2
Loading...
Searching...
No Matches
connection.c File Reference

Methods for managing connections. More...

#include "internal.h"
#include "mhd_limits.h"
#include "connection.h"
#include "memorypool.h"
#include "response.h"
#include "mhd_mono_clock.h"
#include "mhd_str.h"
#include "mhd_sockets.h"
#include "mhd_compat.h"
#include "mhd_itc.h"
#include "mhd_send.h"
#include "mhd_assert.h"
Include dependency graph for connection.c:

Go to the source code of this file.

Macros

#define MHD_ALLOW_BARE_LF_AS_CRLF_(discp_lvl)
 
#define MHD_CHUNK_HEADER_REASONABLE_LEN   24
 
#define HTTP_100_CONTINUE   "HTTP/1.1 100 Continue\r\n\r\n"
 
#define ERR_MSG_REQUEST_TOO_BIG   ""
 
#define ERR_MSG_REQUEST_HEADER_TOO_BIG   ""
 
#define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG   ""
 
#define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG   ""
 
#define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG   ""
 
#define ERR_MSG_REQUEST_FOOTER_TOO_BIG   ""
 
#define RQ_LINE_TOO_MANY_WSP   ""
 
#define BARE_CR_IN_HEADER   ""
 
#define BARE_CR_IN_FOOTER   ""
 
#define BARE_LF_IN_HEADER   ""
 
#define BARE_LF_IN_FOOTER   ""
 
#define RQ_TARGET_INVALID_CHAR   ""
 
#define ERR_RSP_OBS_FOLD   ""
 
#define ERR_RSP_OBS_FOLD_FOOTER   ""
 
#define ERR_RSP_WSP_BEFORE_HEADER   ""
 
#define ERR_RSP_WSP_BEFORE_FOOTER   ""
 
#define ERR_RSP_WSP_IN_HEADER_NAME   ""
 
#define ERR_RSP_WSP_IN_FOOTER_NAME   ""
 
#define ERR_RSP_INVALID_CHR_IN_HEADER   ""
 
#define ERR_RSP_INVALID_CHR_IN_FOOTER   ""
 
#define ERR_RSP_HEADER_WITHOUT_COLON   ""
 
#define ERR_RSP_FOOTER_WITHOUT_COLON   ""
 
#define ERR_RSP_EMPTY_HEADER_NAME   ""
 
#define ERR_RSP_EMPTY_FOOTER_NAME   ""
 
#define REQUEST_LACKS_HOST   ""
 
#define REQUEST_UNSUPPORTED_TR_ENCODING   ""
 
#define REQUEST_LENGTH_WITH_TR_ENCODING   ""
 
#define REQUEST_MALFORMED   ""
 
#define REQUEST_CHUNKED_MALFORMED   ""
 
#define REQUEST_CHUNK_TOO_LARGE   ""
 
#define REQUEST_CONTENTLENGTH_TOOLARGE   ""
 
#define REQUEST_CONTENTLENGTH_MALFORMED   ""
 
#define ERROR_MSG_DATA_NOT_HANDLED_BY_APP   ""
 
#define REQ_HTTP_VER_IS_TOO_OLD   ""
 
#define REQ_HTTP_VER_IS_NOT_SUPPORTED   ""
 
#define MHD_SENFILE_CHUNK_   (0x20000)
 
#define MHD_SENFILE_CHUNK_THR_P_C_   (0x200000)
 
#define MHD_lookup_header_s_token_ci(c, h, tkn)
 
#define CONNECTION_CLOSE_ERROR(c, emsg)
 
#define buffer_append_s(buf, ppos, buf_size, str)
 
#define transmit_error_response_static(c, code, msg)
 
#define transmit_error_response_header(c, code, m, hd_n, hd_n_l, hd_v, hd_v_l)
 
#define MHD_MAX_REASONABLE_HEADERS_SIZE_   (6 * 1024)
 
#define MHD_MAX_REASONABLE_REQ_TARGET_SIZE_   8000
 
#define MHD_MIN_REASONABLE_HEADERS_SIZE_   26
 
#define MHD_MIN_REASONABLE_REQ_TARGET_SIZE_   40
 
#define MHD_MIN_REASONABLE_REQ_METHOD_SIZE_   16
 
#define MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_   4
 
#define HTTP_VER_LEN   (MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1))
 
#define MHD_MAX_EMPTY_LINES_SKIP   1024
 
#define MHD_MAX_FIXED_URI_LEN   (64 * 1024)
 

Enumerations

enum  replyBodyUse { RP_BODY_NONE = 0 , RP_BODY_HEADERS_ONLY = 1 , RP_BODY_SEND = 2 }
 
enum  MHD_ProcRecvDataStage {
  MHD_PROC_RECV_INIT , MHD_PROC_RECV_METHOD , MHD_PROC_RECV_URI , MHD_PROC_RECV_HTTPVER ,
  MHD_PROC_RECV_HEADERS , MHD_PROC_RECV_COOKIE , MHD_PROC_RECV_BODY_NORMAL , MHD_PROC_RECV_BODY_CHUNKED ,
  MHD_PROC_RECV_FOOTERS
}
 
enum  MHD_HdrLineReadRes_ { MHD_HDR_LINE_READING_NEED_MORE_DATA = 0 , MHD_HDR_LINE_READING_GOT_HEADER , MHD_HDR_LINE_READING_DATA_ERROR , MHD_HDR_LINE_READING_GOT_END_OF_HEADER }
 

Functions

void * MHD_connection_alloc_memory_ (struct MHD_Connection *connection, size_t size)
 
static ssize_t recv_param_adapter (struct MHD_Connection *connection, void *other, size_t i)
 
_MHD_EXTERN int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls)
 
_MHD_EXTERN int MHD_get_connection_values_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN 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_set_connection_value (struct MHD_Connection *connection, 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)
 
_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)
 
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)
 
static bool need_100_continue (struct MHD_Connection *connection)
 
void MHD_connection_mark_closed_ (struct MHD_Connection *connection)
 
void MHD_connection_close_ (struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code)
 
static void connection_close_error (struct MHD_Connection *connection, const char *emsg)
 
static enum MHD_Result try_ready_normal_body (struct MHD_Connection *connection)
 
static enum MHD_Result try_ready_chunked_body (struct MHD_Connection *connection, bool *p_finished)
 
static enum MHD_ConnKeepAlive keepalive_possible (struct MHD_Connection *connection)
 
static bool get_date_str (char *date)
 
static bool get_date_header (char *header)
 
static bool try_grow_read_buffer (struct MHD_Connection *connection, bool required)
 
static void connection_shrink_read_buffer (struct MHD_Connection *connection)
 
static size_t connection_maximize_write_buffer (struct MHD_Connection *connection)
 
static void connection_switch_from_recv_to_send (struct MHD_Connection *connection)
 
static enum replyBodyUse is_reply_body_needed (struct MHD_Connection *connection, unsigned int rcode)
 
static void setup_reply_properties (struct MHD_Connection *connection)
 
static void check_connection_reply (struct MHD_Connection *connection)
 
static bool buffer_append (char *buf, size_t *ppos, size_t buf_size, const char *append, size_t append_size)
 
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)
 
static enum MHD_Result build_header_response (struct MHD_Connection *connection)
 
static enum MHD_Result build_connection_chunked_response_footer (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)
 
static bool has_unprocessed_upload_body_data_in_buffer (struct MHD_Connection *c)
 
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)
 
static void handle_req_headers_no_space (struct MHD_Connection *c, const char *add_header, size_t add_header_size)
 
static void handle_req_chunk_size_line_no_space (struct MHD_Connection *c, const char *chunk_size_line, size_t chunk_size_line_size)
 
static void handle_req_footers_no_space (struct MHD_Connection *c, const char *add_footer, size_t add_footer_size)
 
static void handle_recv_no_space (struct MHD_Connection *c, enum MHD_ProcRecvDataStage stage)
 
static bool check_and_grow_read_buffer_space (struct MHD_Connection *c)
 
static void MHD_connection_update_event_loop_info (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 bool parse_http_version (struct MHD_Connection *connection, const char *http_string, size_t len)
 
static void parse_http_std_method (struct MHD_Connection *connection, const char *method, size_t len)
 
static void call_connection_handler (struct MHD_Connection *connection)
 
static void process_request_body (struct MHD_Connection *connection)
 
static enum MHD_Result check_write_done (struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state)
 
static void parse_connection_headers (struct MHD_Connection *connection)
 
_MHD_static_inline void reset_rq_header_processing_state (struct MHD_Connection *c)
 
_MHD_static_inline void switch_to_rq_headers_processing (struct MHD_Connection *c)
 
static bool get_request_line_inner (struct MHD_Connection *c)
 
static void send_redirect_fixed_rq_target (struct MHD_Connection *c)
 
static bool process_request_target (struct MHD_Connection *c)
 
static bool get_request_line (struct MHD_Connection *c)
 
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 bool get_req_headers (struct MHD_Connection *c, bool process_footers)
 
void MHD_update_last_activity_ (struct MHD_Connection *connection)
 
void MHD_connection_handle_read (struct MHD_Connection *connection, bool socket_error)
 
void MHD_connection_handle_write (struct MHD_Connection *connection)
 
static bool connection_check_timedout (struct MHD_Connection *c)
 
static void cleanup_connection (struct MHD_Connection *connection)
 
void MHD_connection_set_initial_state_ (struct MHD_Connection *c)
 
static void connection_reset (struct MHD_Connection *connection, bool reuse)
 
enum MHD_Result MHD_connection_handle_idle (struct MHD_Connection *connection)
 
void MHD_set_http_callbacks_ (struct MHD_Connection *connection)
 
_MHD_EXTERN const union MHD_ConnectionInfoMHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...)
 
_MHD_EXTERN enum MHD_Result MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...)
 
_MHD_EXTERN enum MHD_Result MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
 

Variables

enum MHD_HdrLineReadRes_ _MHD_FIXED_ENUM
 

Detailed Description

Methods for managing connections.

Author
Daniel Pittman
Christian Grothoff
Karlson2k (Evgeny Grin)

Definition in file connection.c.

Macro Definition Documentation

◆ BARE_CR_IN_FOOTER

#define BARE_CR_IN_FOOTER   ""

Response text used when the request HTTP footer has bare CR character without LF character (and CR is not allowed to be treated as whitespace).

Definition at line 228 of file connection.c.

Referenced by get_req_header().

◆ BARE_CR_IN_HEADER

#define BARE_CR_IN_HEADER   ""

Response text used when the request HTTP header has bare CR character without LF character (and CR is not allowed to be treated as whitespace).

Definition at line 213 of file connection.c.

Referenced by get_req_header(), and get_request_line_inner().

◆ BARE_LF_IN_FOOTER

#define BARE_LF_IN_FOOTER   ""

Response text used when the request HTTP footer has bare LF character without CR character.

Definition at line 258 of file connection.c.

Referenced by get_req_header().

◆ BARE_LF_IN_HEADER

#define BARE_LF_IN_HEADER   ""

Response text used when the request HTTP header has bare LF character without CR character.

Definition at line 243 of file connection.c.

Referenced by get_req_header(), and get_request_line_inner().

◆ buffer_append_s

#define buffer_append_s ( buf,
ppos,
buf_size,
str )
Value:
buffer_append (buf,ppos,buf_size,str, MHD_STATICSTR_LEN_ (str))
static bool buffer_append(char *buf, size_t *ppos, size_t buf_size, const char *append, size_t append_size)
#define MHD_STATICSTR_LEN_(macro)

Append static string to the buffer if enough space is available, update position.

Parameters
[out]bufthe buffer to append data to
[in,out]pposthe pointer to position in the buffer
buf_sizethe size of the buffer
strthe static string to append
Returns
true if data has been added and position has been updated, false if not enough space is available

Definition at line 2331 of file connection.c.

Referenced by build_header_response().

◆ CONNECTION_CLOSE_ERROR

#define CONNECTION_CLOSE_ERROR ( c,
emsg )
Value:
static void connection_close_error(struct MHD_Connection *connection, const char *emsg)
#define NULL

Macro to only include error message in call to connection_close_error() if we have HAVE_MESSAGES.

Definition at line 1386 of file connection.c.

Referenced by call_connection_handler(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_connection_handle_write(), process_request_body(), transmit_error_response_len(), try_ready_chunked_body(), and try_ready_normal_body().

◆ ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG

#define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG   ""

Response text used when the request chunk size line with chunk extension cannot fit the buffer.

Definition at line 148 of file connection.c.

Referenced by handle_req_chunk_size_line_no_space().

◆ ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG

#define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG   ""

Response text used when the request chunk size line without chunk extension cannot fit the buffer.

Definition at line 167 of file connection.c.

Referenced by handle_req_chunk_size_line_no_space().

◆ ERR_MSG_REQUEST_FOOTER_TOO_BIG

#define ERR_MSG_REQUEST_FOOTER_TOO_BIG   ""

Response text used when the request header is too big to be processed.

Definition at line 185 of file connection.c.

Referenced by handle_req_footers_no_space().

◆ ERR_MSG_REQUEST_HEADER_TOO_BIG

#define ERR_MSG_REQUEST_HEADER_TOO_BIG   ""

Response text used when the request header is too big to be processed.

Definition at line 111 of file connection.c.

Referenced by handle_req_headers_no_space().

◆ ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG

#define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG   ""

Response text used when the request cookie header is too big to be processed.

Definition at line 129 of file connection.c.

◆ ERR_MSG_REQUEST_TOO_BIG

#define ERR_MSG_REQUEST_TOO_BIG   ""

Response text used when the request (http header) is too big to be processed.

Definition at line 94 of file connection.c.

Referenced by connection_add_header(), and handle_recv_no_space().

◆ ERR_RSP_EMPTY_FOOTER_NAME

#define ERR_RSP_EMPTY_FOOTER_NAME   ""

Response text used when request header has zero-length header (filed) name.

Definition at line 436 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_EMPTY_HEADER_NAME

#define ERR_RSP_EMPTY_HEADER_NAME   ""

Response text used when request header has zero-length header (filed) name.

Definition at line 423 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_FOOTER_WITHOUT_COLON

#define ERR_RSP_FOOTER_WITHOUT_COLON   ""

Response text used when request footer has no colon character.

Definition at line 410 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_HEADER_WITHOUT_COLON

#define ERR_RSP_HEADER_WITHOUT_COLON   ""

Response text used when request header has no colon character.

Definition at line 397 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_INVALID_CHR_IN_FOOTER

#define ERR_RSP_INVALID_CHR_IN_FOOTER   ""

Response text used when request header has invalid character.

Definition at line 384 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_INVALID_CHR_IN_HEADER

#define ERR_RSP_INVALID_CHR_IN_HEADER   ""

Response text used when request header has invalid character.

Definition at line 371 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_OBS_FOLD

#define ERR_RSP_OBS_FOLD   ""

Response text used when line folding is used in request headers.

Definition at line 285 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_OBS_FOLD_FOOTER

#define ERR_RSP_OBS_FOLD_FOOTER   ""

Response text used when line folding is used in request footers.

Definition at line 298 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_WSP_BEFORE_FOOTER

#define ERR_RSP_WSP_BEFORE_FOOTER   ""

Response text used when the request has whitespace at the start of the first footer line.

Definition at line 328 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_WSP_BEFORE_HEADER

#define ERR_RSP_WSP_BEFORE_HEADER   ""

Response text used when the request has whitespace at the start of the first header line.

Definition at line 313 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_WSP_IN_FOOTER_NAME

#define ERR_RSP_WSP_IN_FOOTER_NAME   ""

Response text used when the whitespace found before colon (inside header name or between header name and colon).

Definition at line 358 of file connection.c.

Referenced by get_req_header().

◆ ERR_RSP_WSP_IN_HEADER_NAME

#define ERR_RSP_WSP_IN_HEADER_NAME   ""

Response text used when the whitespace found before colon (inside header name or between header name and colon).

Definition at line 343 of file connection.c.

Referenced by get_req_header().

◆ ERROR_MSG_DATA_NOT_HANDLED_BY_APP

#define ERROR_MSG_DATA_NOT_HANDLED_BY_APP   ""

Response text used when there is an internal server error.

Intentionally empty here to keep our memory footprint minimal.

Definition at line 562 of file connection.c.

Referenced by handle_recv_no_space().

◆ HTTP_100_CONTINUE

#define HTTP_100_CONTINUE   "HTTP/1.1 100 Continue\r\n\r\n"

Message to transmit when http 1.1 request is received

Definition at line 80 of file connection.c.

Referenced by MHD_connection_handle_idle(), and MHD_connection_handle_write().

◆ HTTP_VER_LEN

#define HTTP_VER_LEN   (MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1))

The valid length of any HTTP version string

Definition at line 4244 of file connection.c.

Referenced by get_req_headers(), get_request_line(), get_request_line_inner(), and parse_http_version().

◆ MHD_ALLOW_BARE_LF_AS_CRLF_

#define MHD_ALLOW_BARE_LF_AS_CRLF_ ( discp_lvl)
Value:
(0 >= discp_lvl)

Get whether bare LF in HTTP header and other protocol elements should be treated as the line termination depending on the configured strictness level. RFC 9112, section 2.2

Definition at line 65 of file connection.c.

Referenced by get_req_header(), get_request_line_inner(), and process_request_body().

◆ MHD_CHUNK_HEADER_REASONABLE_LEN

#define MHD_CHUNK_HEADER_REASONABLE_LEN   24

The reasonable length of the upload chunk "header" (the size specifier with optional chunk extension). MHD tries to keep the space in the read buffer large enough to read the chunk "header" in one step. The real "header" could be much larger, it will be handled correctly anyway, however it may require several rounds of buffer grow.

Definition at line 75 of file connection.c.

Referenced by check_and_grow_read_buffer_space().

◆ MHD_lookup_header_s_token_ci

#define MHD_lookup_header_s_token_ci ( c,
h,
tkn )
Value:
(tkn),MHD_STATICSTR_LEN_ (tkn))
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)

Check whether request header contains particular static tkn.

Token could be surrounded by spaces and tabs and delimited by comma. Case-insensitive match used for header names and tokens.

Parameters
cthe connection to get values from
hthe static string of header name
tknthe static string of token to find
Returns
true if token is found in specified header, false otherwise

Definition at line 1160 of file connection.c.

Referenced by keepalive_possible().

◆ MHD_MAX_EMPTY_LINES_SKIP

#define MHD_MAX_EMPTY_LINES_SKIP   1024

The maximum number of ignored empty line before the request line at default "strictness" level.

Definition at line 4886 of file connection.c.

Referenced by get_request_line_inner().

◆ MHD_MAX_FIXED_URI_LEN

#define MHD_MAX_FIXED_URI_LEN   (64 * 1024)

The maximum size of the fixed URI for automatic redirection

Definition at line 5446 of file connection.c.

Referenced by send_redirect_fixed_rq_target().

◆ MHD_MAX_REASONABLE_HEADERS_SIZE_

#define MHD_MAX_REASONABLE_HEADERS_SIZE_   (6 * 1024)

A reasonable headers size (excluding request line) that should be sufficient for most requests. If incoming data buffer free space is not enough to process the complete header (the request line and all headers) and the headers size is larger than this size then the status code 431 "Request Header Fields Too Large" is returned to the client. The larger headers are processed by MHD if enough space is available.

Definition at line 3006 of file connection.c.

Referenced by get_no_space_err_status_code().

◆ MHD_MAX_REASONABLE_REQ_TARGET_SIZE_

#define MHD_MAX_REASONABLE_REQ_TARGET_SIZE_   8000

A reasonable request target (the request URI) size that should be sufficient for most requests. If incoming data buffer free space is not enough to process the complete header (the request line and all headers) and the request target size is larger than this size then the status code 414 "URI Too Long" is returned to the client. The larger request targets are processed by MHD if enough space is available. The value chosen according to RFC 9112 Section 3, paragraph 5

Definition at line 3020 of file connection.c.

Referenced by get_no_space_err_status_code().

◆ MHD_MIN_REASONABLE_HEADERS_SIZE_

#define MHD_MIN_REASONABLE_HEADERS_SIZE_   26

A reasonable headers size (excluding request line) that should be sufficient for basic simple requests. When no space left in the receiving buffer try to avoid replying with the status code 431 "Request Header Fields Too Large" if headers size is smaller then this value.

Definition at line 3031 of file connection.c.

Referenced by get_no_space_err_status_code().

◆ MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_

#define MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_   4

A reasonable minimal chunk line length. When no space left in the receiving buffer reply with 413 "Content Too Large" if the chunk line length is larger than this value.

Definition at line 3062 of file connection.c.

Referenced by get_no_space_err_status_code().

◆ MHD_MIN_REASONABLE_REQ_METHOD_SIZE_

#define MHD_MIN_REASONABLE_REQ_METHOD_SIZE_   16

A reasonable request method string size that should be sufficient for basic simple requests. When no space left in the receiving buffer try to avoid replying with the status code 501 "Not Implemented" if the request method size is smaller then this value.

Definition at line 3053 of file connection.c.

Referenced by get_no_space_err_status_code().

◆ MHD_MIN_REASONABLE_REQ_TARGET_SIZE_

#define MHD_MIN_REASONABLE_REQ_TARGET_SIZE_   40

A reasonable request target (the request URI) size that should be sufficient for basic simple requests. When no space left in the receiving buffer try to avoid replying with the status code 414 "URI Too Long" if the request target size is smaller then this value.

Definition at line 3042 of file connection.c.

Referenced by get_no_space_err_status_code().

◆ MHD_SENFILE_CHUNK_

#define MHD_SENFILE_CHUNK_   (0x20000)

sendfile() chuck size

Definition at line 592 of file connection.c.

◆ MHD_SENFILE_CHUNK_THR_P_C_

#define MHD_SENFILE_CHUNK_THR_P_C_   (0x200000)

sendfile() chuck size for thread-per-connection

Definition at line 597 of file connection.c.

◆ REQ_HTTP_VER_IS_NOT_SUPPORTED

#define REQ_HTTP_VER_IS_NOT_SUPPORTED   ""

Response text used when the request HTTP version is not supported.

Definition at line 585 of file connection.c.

Referenced by parse_http_version().

◆ REQ_HTTP_VER_IS_TOO_OLD

#define REQ_HTTP_VER_IS_TOO_OLD   ""

Response text used when the request HTTP version is too old.

Definition at line 574 of file connection.c.

Referenced by parse_http_version().

◆ REQUEST_CHUNK_TOO_LARGE

#define REQUEST_CHUNK_TOO_LARGE   ""

Response text used when the request HTTP chunk is too large.

Definition at line 521 of file connection.c.

Referenced by process_request_body().

◆ REQUEST_CHUNKED_MALFORMED

#define REQUEST_CHUNKED_MALFORMED   ""

Response text used when the request HTTP chunked encoding is malformed.

Definition at line 509 of file connection.c.

Referenced by process_request_body().

◆ REQUEST_CONTENTLENGTH_MALFORMED

#define REQUEST_CONTENTLENGTH_MALFORMED   ""

Response text used when the request HTTP chunked encoding is malformed.

Definition at line 546 of file connection.c.

Referenced by parse_connection_headers().

◆ REQUEST_CONTENTLENGTH_TOOLARGE

#define REQUEST_CONTENTLENGTH_TOOLARGE   ""

Response text used when the request HTTP content is too large.

Definition at line 533 of file connection.c.

Referenced by parse_connection_headers().

◆ REQUEST_LACKS_HOST

#define REQUEST_LACKS_HOST   ""

Response text used when the request (http header) does not contain a "Host:" header and still claims to be HTTP 1.1.

Intentionally empty here to keep our memory footprint minimal.

Definition at line 454 of file connection.c.

Referenced by parse_connection_headers().

◆ REQUEST_LENGTH_WITH_TR_ENCODING

#define REQUEST_LENGTH_WITH_TR_ENCODING   ""

Response text used when the request has unsupported both headers: "Transfer-Encoding:" and "Content-Length:"

Definition at line 482 of file connection.c.

Referenced by parse_connection_headers().

◆ REQUEST_MALFORMED

#define REQUEST_MALFORMED   ""

Response text used when the request (http header) is malformed.

Intentionally empty here to keep our memory footprint minimal.

Definition at line 497 of file connection.c.

Referenced by get_request_line(), get_request_line_inner(), and parse_http_version().

◆ REQUEST_UNSUPPORTED_TR_ENCODING

#define REQUEST_UNSUPPORTED_TR_ENCODING   ""

Response text used when the request has unsupported "Transfer-Encoding:".

Definition at line 467 of file connection.c.

Referenced by parse_connection_headers().

◆ RQ_LINE_TOO_MANY_WSP

#define RQ_LINE_TOO_MANY_WSP   ""

Response text used when the request line has more then two whitespaces.

Definition at line 198 of file connection.c.

Referenced by get_request_line_inner().

◆ RQ_TARGET_INVALID_CHAR

#define RQ_TARGET_INVALID_CHAR   ""

Response text used when the request line has invalid characters in URI.

Definition at line 272 of file connection.c.

Referenced by get_request_line(), and send_redirect_fixed_rq_target().

◆ transmit_error_response_header

#define transmit_error_response_header ( c,
code,
m,
hd_n,
hd_n_l,
hd_v,
hd_v_l )
Value:
hd_n, hd_n_l, \
hd_v, hd_v_l)
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)

Transmit static string as error response and add specified header

Definition at line 2942 of file connection.c.

Referenced by send_redirect_fixed_rq_target().

◆ transmit_error_response_static

Enumeration Type Documentation

◆ MHD_HdrLineReadRes_

Results of header line reading

Enumerator
MHD_HDR_LINE_READING_NEED_MORE_DATA 

Not enough data yet

MHD_HDR_LINE_READING_GOT_HEADER 

New header line has been read

MHD_HDR_LINE_READING_DATA_ERROR 

Error in header data, error response has been queued

MHD_HDR_LINE_READING_GOT_END_OF_HEADER 

Found the end of the request header (end of field lines)

Definition at line 5684 of file connection.c.

◆ MHD_ProcRecvDataStage

The stage of input data processing. Used for out-of-memory (in the pool) handling.

Enumerator
MHD_PROC_RECV_INIT 

No data HTTP request data have been processed yet

MHD_PROC_RECV_METHOD 

Processing/receiving the request HTTP method

MHD_PROC_RECV_URI 

Processing/receiving the request URI

MHD_PROC_RECV_HTTPVER 

Processing/receiving the request HTTP version string

MHD_PROC_RECV_HEADERS 

Processing/receiving the request HTTP headers

MHD_PROC_RECV_COOKIE 

Processing the received request cookie header

MHD_PROC_RECV_BODY_NORMAL 

Processing/receiving the request non-chunked body

MHD_PROC_RECV_BODY_CHUNKED 

Processing/receiving the request chunked body

MHD_PROC_RECV_FOOTERS 

Processing/receiving the request footers

Definition at line 2982 of file connection.c.

◆ replyBodyUse

This enum type describes requirements for reply body and reply bode-specific headers (namely Content-Length, Transfer-Encoding).

Enumerator
RP_BODY_NONE 

No reply body allowed. Reply body headers 'Content-Length:' or 'Transfer-Encoding: chunked' are not allowed as well.

RP_BODY_HEADERS_ONLY 

Do not send reply body. Reply body headers 'Content-Length:' or 'Transfer-Encoding: chunked' are allowed, but optional.

RP_BODY_SEND 

Send reply body and reply body headers 'Content-Length:' or 'Transfer-Encoding: chunked'. Reply body headers are required.

Definition at line 2103 of file connection.c.

Function Documentation

◆ add_user_headers()

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 )
static

Add user-defined headers from response object to the text buffer.

Parameters
bufthe buffer to add headers to
pposthe pointer to the position in the buf
buf_sizethe size of the buf
responsethe response
filter_transf_encskip "Transfer-Encoding" header if any
filter_content_lenskip "Content-Length" header if any
add_closeadd "close" token to the "Connection:" header (if any), ignored if no "Connection:" header was added by user or if "close" token is already present in "Connection:" header
add_keep_aliveadd "Keep-Alive" token to the "Connection:" header (if any)
Returns
true if succeed, false if buffer is too small

< a short alias

< Iterates through User-specified headers

< the size of current element to be added to the buf

Definition at line 2355 of file connection.c.

References MHD_Response::first_header, MHD_Response::flags, MHD_Response::flags_auto, MHD_HTTP_Res_Header::header, MHD_HTTP_Res_Header::header_size, MHD_HTTP_Res_Header::kind, mhd_assert, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_HTTP_HEADER_TRANSFER_ENCODING, MHD_RAF_HAS_CONNECTION_CLOSE, MHD_RAF_HAS_CONNECTION_HDR, MHD_RAF_HAS_CONTENT_LENGTH, MHD_RAF_HAS_TRANS_ENC_CHUNKED, MHD_RF_INSANITY_HEADER_CONTENT_LENGTH, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_bin_n_(), MHD_str_equal_caseless_n_(), MHD_HTTP_Res_Header::next, NULL, MHD_HTTP_Res_Header::value, and MHD_HTTP_Res_Header::value_size.

Referenced by build_header_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buffer_append()

static bool buffer_append ( char * buf,
size_t * ppos,
size_t buf_size,
const char * append,
size_t append_size )
static

Append data to the buffer if enough space is available, update position.

Parameters
[out]bufthe buffer to append data to
[in,out]pposthe pointer to position in the buffer
buf_sizethe size of the buffer
appendthe data to append
append_sizethe size of the append
Returns
true if data has been added and position has been updated, false if not enough space is available

Definition at line 2306 of file connection.c.

References mhd_assert, and NULL.

Referenced by build_header_response().

Here is the caller graph for this function:

◆ build_connection_chunked_response_footer()

static enum MHD_Result build_connection_chunked_response_footer ( struct MHD_Connection * connection)
static

Allocate the connection's write buffer (if necessary) and fill it with response footers. Works only for chunked responses as other responses do not need and do not support any kind of footers.

Parameters
connectionthe connection
Returns
MHD_YES on success, MHD_NO on failure (out of memory)

< the buffer to write footers to

< the size of the buf

< the used size of the buf

< a short alias

Definition at line 2700 of file connection.c.

References MHD_Reply_Properties::chunked, connection_maximize_write_buffer(), MHD_Response::first_header, MHD_HTTP_Res_Header::header, MHD_HTTP_Res_Header::header_size, MHD_HTTP_Res_Header::kind, mhd_assert, MHD_CONNECTION_CHUNKED_BODY_SENT, MHD_FOOTER_KIND, MHD_NO, MHD_YES, MHD_HTTP_Res_Header::next, NULL, MHD_Reply::props, MHD_Reply::response, MHD_Connection::rp, MHD_Connection::state, MHD_HTTP_Res_Header::value, MHD_HTTP_Res_Header::value_size, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_size.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_header_response()

static enum MHD_Result build_header_response ( struct MHD_Connection * connection)
static

Allocate the connection's write buffer and fill it with all of the headers from the response. Required headers are added here.

Parameters
connectionthe connection
Returns
MHD_YES on success, MHD_NO on failure (out of memory)

< a short alias

< a short alias

< the output buffer

< append offset in the buf

< the size of the buf

< the size of current element to be added to the buf

< the response code

< Use "Connection: close" header

< Use "Connection: Keep-Alive" header

Definition at line 2468 of file connection.c.

References add_user_headers(), buffer_append(), buffer_append_s, check_connection_reply(), MHD_Reply_Properties::chunked, connection_maximize_write_buffer(), MHD_Connection::daemon, MHD_Response::flags, MHD_Response::flags_auto, get_date_header(), MHD_Request::http_ver, MHD_Connection::keepalive, mhd_assert, MHD_CONN_MUST_CLOSE, MHD_CONN_MUST_UPGRADE, MHD_CONN_USE_KEEPALIVE, MHD_get_reason_phrase_for(), MHD_get_reason_phrase_len_for(), MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_HTTP_HEADER_TRANSFER_ENCODING, MHD_HTTP_VER_1_0, MHD_HTTP_VERSION_1_0, MHD_HTTP_VERSION_1_1, MHD_NO, MHD_RAF_HAS_CONNECTION_HDR, MHD_RAF_HAS_CONTENT_LENGTH, MHD_RAF_HAS_DATE_HDR, MHD_RAF_HAS_TRANS_ENC_CHUNKED, MHD_RF_HEAD_ONLY_RESPONSE, MHD_RF_HTTP_1_0_SERVER, MHD_RF_INSANITY_HEADER_CONTENT_LENGTH, MHD_RF_SEND_KEEP_ALIVE_HEADER, MHD_SIZE_UNKNOWN, MHD_uint16_to_str(), MHD_uint64_to_str(), MHD_USE_SUPPRESS_DATE_NO_CLOCK, MHD_YES, NULL, MHD_Daemon::options, MHD_Reply::props, MHD_Reply::response, MHD_Reply::responseCode, MHD_Reply::responseIcy, MHD_Connection::rp, MHD_Connection::rq, MHD_Reply_Properties::send_reply_body, setup_reply_properties(), MHD_Response::total_size, MHD_Reply_Properties::use_reply_body_headers, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_size.

Referenced by MHD_connection_handle_idle(), and transmit_error_response_len().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ call_connection_handler()

static void call_connection_handler ( struct MHD_Connection * connection)
static

Call the handler of the application for this connection. Handles chunking of the upload as well as normal uploads.

Parameters
connectionconnection we're processing

Definition at line 4362 of file connection.c.

References _, MHD_Request::client_aware, MHD_Request::client_context, CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_Daemon::default_handler, MHD_Daemon::default_handler_cls, MHD_Connection::in_access_handler, MHD_Request::method, MHD_NO, NULL, MHD_Reply::response, MHD_Connection::rp, MHD_Connection::rq, MHD_Request::url, and MHD_Request::version.

Referenced by MHD_connection_handle_idle().

Here is the caller graph for this function:

◆ check_and_grow_read_buffer_space()

static bool check_and_grow_read_buffer_space ( struct MHD_Connection * c)
static

Check whether enough space is available in the read buffer for the next operation. Handles grow of the buffer if required and error conditions (when buffer grow is required but not possible). Must be called only when processing the event loop states and when reading is required for the next phase.

Parameters
cthe connection to check
Returns
true if connection handled successfully and enough buffer is available, false if not enough buffer is available and the loop's states must be processed again as connection is in the error state.

The increase of read buffer size is desirable.

The increase of read buffer size is a hard requirement.

Definition at line 3558 of file connection.c.

References MHD_Request::current_chunk_offset, MHD_Request::current_chunk_size, MHD_Connection::daemon, MHD_Connection::discard_request, MHD_Connection::event_loop_info, handle_recv_no_space(), has_unprocessed_upload_body_data_in_buffer(), MHD_Request::have_chunked_upload, MHD_Request::http_mthd, mhd_assert, MHD_CHUNK_HEADER_REASONABLE_LEN, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_RECEIVING, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FULL_REPLY_SENT, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_CONNECTION_HEADERS_SENT, MHD_CONNECTION_INIT, MHD_CONNECTION_NORMAL_BODY_READY, MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_CONNECTION_START_REPLY, MHD_D_IS_USING_THREADS_, MHD_EVENT_LOOP_INFO_PROCESS, MHD_EVENT_LOOP_INFO_READ, MHD_HTTP_MTHD_NO_METHOD, MHD_PROC_RECV_BODY_CHUNKED, MHD_PROC_RECV_BODY_NORMAL, MHD_PROC_RECV_FOOTERS, MHD_PROC_RECV_HEADERS, MHD_PROC_RECV_HTTPVER, MHD_PROC_RECV_INIT, MHD_PROC_RECV_METHOD, MHD_PROC_RECV_URI, MHD_SIZE_UNKNOWN, MHD_Daemon::pool_increment, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Request::remaining_upload_size, MHD_Request::req_target_len, MHD_Connection::rq, MHD_Connection::state, and try_grow_read_buffer().

Referenced by MHD_connection_update_event_loop_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_connection_reply()

static void check_connection_reply ( struct MHD_Connection * connection)
static

Check whether queued response is suitable for connection.

Parameters
connectionto connection to check

< a short alias

< a short alias

Definition at line 2263 of file connection.c.

References _, MHD_Connection::daemon, MHD_Response::flags_auto, mhd_assert, MHD_RAF_HAS_CONTENT_LENGTH, MHD_Reply::props, MHD_Reply::response, MHD_Reply::responseCode, MHD_Connection::rp, MHD_Response::total_size, and MHD_Reply_Properties::use_reply_body_headers.

Referenced by build_header_response().

Here is the caller graph for this function:

◆ check_write_done()

static enum MHD_Result check_write_done ( struct MHD_Connection * connection,
enum MHD_CONNECTION_STATE next_state )
static

Check if we are done sending the write-buffer. If so, transition into "next_state".

Parameters
connectionconnection to check write status for
next_statethe next state to transition to
Returns
MHD_NO if we are not done, MHD_YES if we are

Definition at line 4696 of file connection.c.

References MHD_NO, MHD_YES, MHD_Connection::state, MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_send_offset.

Referenced by MHD_connection_handle_write().

Here is the caller graph for this function:

◆ cleanup_connection()

◆ connection_add_header()

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

Add an entry to the HTTP headers of a connection. If this fails, transmit an error response (request too big).

Parameters
clsthe context (connection)
kindkind of the value
keykey for the value
key_sizenumber of bytes in key
valuethe value itself
value_sizenumber of bytes in value
Returns
MHD_NO on failure (out of memory), MHD_YES for success

Definition at line 3878 of file connection.c.

References _, MHD_Connection::daemon, ERR_MSG_REQUEST_TOO_BIG, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, MHD_NO, MHD_set_connection_value_n(), MHD_YES, and transmit_error_response_static.

Referenced by process_request_target().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection_check_timedout()

static bool connection_check_timedout ( struct MHD_Connection * c)
static

Check whether connection has timed out.

Parameters
cthe connection to check
Returns
true if connection has timeout and needs to be closed, false otherwise.

Definition at line 6922 of file connection.c.

References _, MHD_Connection::connection_timeout_ms, MHD_Connection::daemon, MHD_Connection::last_activity, MHD_monotonic_msec_counter(), PRIu64, MHD_Connection::suspended, and UINT64_MAX.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection_close_error()

static void connection_close_error ( struct MHD_Connection * connection,
const char * emsg )
static

A serious error occurred, close the connection (and notify the application).

Parameters
connectionconnection to close with error
emsgerror message (can be NULL)

Definition at line 1361 of file connection.c.

References MHD_Connection::daemon, MHD_Connection::discard_request, MHD_connection_close_(), MHD_REQUEST_TERMINATED_WITH_ERROR, NULL, and MHD_Connection::stop_with_error.

Referenced by get_request_line_inner(), handle_recv_no_space(), and send_redirect_fixed_rq_target().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection_maximize_write_buffer()

static size_t connection_maximize_write_buffer ( struct MHD_Connection * connection)
static

Allocate the maximum available amount of memory from MemoryPool for write buffer.

Parameters
connectionthe connection whose write buffer is being manipulated
Returns
the size of the free space in the write buffer

< a short alias

Definition at line 1997 of file connection.c.

References mhd_assert, MHD_pool_get_free(), MHD_pool_is_resizable_inplace(), MHD_pool_reallocate(), NULL, MHD_Connection::pool, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, MHD_Connection::write_buffer_send_offset, and MHD_Connection::write_buffer_size.

Referenced by build_connection_chunked_response_footer(), and build_header_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection_reset()

◆ connection_shrink_read_buffer()

static void connection_shrink_read_buffer ( struct MHD_Connection * connection)
static

Shrink connection read buffer to the zero size of free space in the buffer

Parameters
connectionthe connection whose read buffer is being manipulated

< a short alias

Definition at line 1958 of file connection.c.

References mhd_assert, MHD_pool_deallocate(), MHD_pool_is_resizable_inplace(), MHD_pool_reallocate(), NULL, MHD_Connection::pool, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, and MHD_Connection::read_buffer_size.

Referenced by connection_switch_from_recv_to_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connection_switch_from_recv_to_send()

static void connection_switch_from_recv_to_send ( struct MHD_Connection * connection)
static

Switch connection from recv mode to send mode.

Current request header or body will not be read anymore, response must be assigned to connection.

Parameters
connectionthe connection to prepare for sending.

Definition at line 2092 of file connection.c.

References connection_shrink_read_buffer().

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_date_header()

static bool get_date_header ( char * header)
static

Produce HTTP DATE header. Result is always 37 bytes long (plus one terminating null).

Parameters
[out]headerwhere to write the header, with at least 38 bytes available space.

Definition at line 1844 of file connection.c.

References get_date_str().

Referenced by build_header_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_date_str()

static bool get_date_str ( char * date)
static

Produce time stamp.

Result is NOT null-terminated. Result is always 29 bytes long.

Parameters
[out]datewhere to write the time stamp, with at least 29 bytes available space.

Definition at line 1759 of file connection.c.

References MHD_uint16_to_str(), MHD_uint8_to_str_pad(), and NULL.

Referenced by get_date_header().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_no_space_err_status_code()

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 )
static

Select the HTTP error status code for "out of receive buffer space" error.

Parameters
cthe connection to process
stagethe current stage of request receiving
add_elementthe optional pointer to the element failed to be processed or added, the meaning of the element depends on the stage. Could be not zero-terminated and can contain binary zeros. Can be NULL.
add_element_sizethe size of the add_element
Returns
the HTTP error code to use in the error reply

Definition at line 3078 of file connection.c.

References MHD_Request::field_lines, MHD_Request::http_mthd, MHD_Request::method, mhd_assert, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_HEADER_KIND, MHD_HTTP_CONTENT_TOO_LARGE, MHD_HTTP_HEADER_HOST, MHD_HTTP_MTHD_OTHER, MHD_HTTP_NOT_IMPLEMENTED, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, MHD_HTTP_URI_TOO_LONG, MHD_lookup_connection_value_n(), MHD_MAX_REASONABLE_HEADERS_SIZE_, MHD_MAX_REASONABLE_REQ_TARGET_SIZE_, MHD_MIN_REASONABLE_HEADERS_SIZE_, MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_, MHD_MIN_REASONABLE_REQ_METHOD_SIZE_, MHD_MIN_REASONABLE_REQ_TARGET_SIZE_, MHD_NO, MHD_PROC_RECV_BODY_CHUNKED, MHD_PROC_RECV_HEADERS, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_bin_n_(), NULL, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Request::req_target_len, MHD_Connection::rq, MHD_StartOrSize::size, MHD_StartOrSize::start, and MHD_Connection::state.

Referenced by handle_req_chunk_size_line_no_space(), and handle_req_headers_no_space().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_req_header()

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

Find the end of the request header line and make basic header parsing. Handle errors and header folding.

Parameters
cthe connection to process
process_footersif true then footers are processed, if false then headers are processed
[out]hdr_namethe name of the parsed header (field)
[out]hdr_namethe value of the parsed header (field)
Returns
true if request header line completely processed, false if not enough data yet in the receive buffer

< The position of the currently processed character

The full length of the line, including CRLF (or bare LF).

Definition at line 5717 of file connection.c.

References _, BARE_CR_IN_FOOTER, BARE_CR_IN_HEADER, BARE_LF_IN_FOOTER, BARE_LF_IN_HEADER, MHD_Daemon::client_discipline, MHD_Connection::daemon, ERR_RSP_EMPTY_FOOTER_NAME, ERR_RSP_EMPTY_HEADER_NAME, ERR_RSP_FOOTER_WITHOUT_COLON, ERR_RSP_HEADER_WITHOUT_COLON, ERR_RSP_INVALID_CHR_IN_FOOTER, ERR_RSP_INVALID_CHR_IN_HEADER, ERR_RSP_OBS_FOLD, ERR_RSP_OBS_FOLD_FOOTER, ERR_RSP_WSP_BEFORE_FOOTER, ERR_RSP_WSP_BEFORE_HEADER, ERR_RSP_WSP_IN_FOOTER_NAME, ERR_RSP_WSP_IN_HEADER_NAME, MHD_HeadersProcessing::hdr, MHD_Request::hdrs, _MHD_str_w_len::len, MHD_ALLOW_BARE_LF_AS_CRLF_, mhd_assert, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_HDR_LINE_READING_DATA_ERROR, MHD_HDR_LINE_READING_GOT_END_OF_HEADER, MHD_HDR_LINE_READING_GOT_HEADER, MHD_HDR_LINE_READING_NEED_MORE_DATA, MHD_HTTP_BAD_REQUEST, MHD_HeaderProcessing::name_end_found, MHD_HeaderProcessing::name_len, MHD_Request::num_cr_sp_replaced, MHD_HeaderProcessing::proc_pos, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::rq, MHD_Request::skipped_broken_lines, MHD_HeaderProcessing::starts_with_ws, MHD_Connection::state, _MHD_str_w_len::str, transmit_error_response_static, MHD_HeaderProcessing::value_start, and MHD_HeaderProcessing::ws_start.

Referenced by get_req_headers().

Here is the caller graph for this function:

◆ get_req_headers()

static bool get_req_headers ( struct MHD_Connection * c,
bool process_footers )
static

Find the end of the request headers and make basic header parsing. Advance to the next state when done, handle errors.

Parameters
cthe connection to process
process_footersif true then footers are processed, if false then headers are processed
Returns
true if request headers reading finished (either successfully or with error), false if not enough data yet in the receive buffer

The position of the terminating NUL after the last character of the last header element.

Definition at line 6182 of file connection.c.

References _, MHD_Connection::daemon, MHD_Connection::discard_request, MHD_Request::field_lines, get_req_header(), handle_req_footers_no_space(), handle_req_headers_no_space(), MHD_Request::header_size, MHD_Request::headers_received_tail, HTTP_VER_LEN, _MHD_str_w_len::len, MHD_Request::method, mhd_assert, MHD_BUF_INC_SIZE, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_FOOTER_KIND, MHD_HDR_LINE_READING_DATA_ERROR, MHD_HDR_LINE_READING_GOT_END_OF_HEADER, MHD_HDR_LINE_READING_GOT_HEADER, MHD_HDR_LINE_READING_NEED_MORE_DATA, MHD_HEADER_KIND, MHD_NO, MHD_set_connection_value_n_nocheck_(), NULL, MHD_Request::num_cr_sp_replaced, PRIu64, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, reset_rq_header_processing_state(), MHD_Connection::rq, MHD_StartOrSize::size, MHD_Request::skipped_broken_lines, MHD_StartOrSize::start, MHD_Connection::state, MHD_Connection::stop_with_error, _MHD_str_w_len::str, MHD_HTTP_Req_Header::value, MHD_HTTP_Req_Header::value_size, and MHD_Request::version.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_request_line()

static bool get_request_line ( struct MHD_Connection * c)
static

◆ get_request_line_inner()

static bool get_request_line_inner ( struct MHD_Connection * c)
static

Find and parse the request line.

Parameters
cthe connection to process
Returns
true if request line completely processed (or unrecoverable error found) and state is changed, false if not enough data yet in the receive buffer

< The current processing position

Definition at line 4897 of file connection.c.

References _, BARE_CR_IN_HEADER, BARE_LF_IN_HEADER, MHD_Daemon::client_discipline, connection_close_error(), MHD_Connection::daemon, MHD_Request::hdrs, MHD_Request::http_mthd, HTTP_VER_LEN, MHD_RequestLineProcessing::last_ws_end, MHD_RequestLineProcessing::last_ws_start, MHD_Request::method, MHD_ALLOW_BARE_LF_AS_CRLF_, mhd_assert, MHD_CONNECTION_INIT, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_HTTP_BAD_REQUEST, MHD_HTTP_MTHD_DELETE, MHD_HTTP_MTHD_GET, MHD_HTTP_MTHD_NO_METHOD, MHD_MAX_EMPTY_LINES_SKIP, NULL, MHD_Request::num_cr_sp_replaced, MHD_RequestLineProcessing::num_ws_in_uri, parse_http_std_method(), parse_http_version(), MHD_RequestLineProcessing::proc_pos, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Request::req_target_len, REQUEST_MALFORMED, MHD_Connection::rq, MHD_HeadersProcessing::rq_line, RQ_LINE_TOO_MANY_WSP, MHD_RequestLineProcessing::rq_tgt, MHD_RequestLineProcessing::rq_tgt_qmark, MHD_RequestLineProcessing::skipped_empty_lines, MHD_Connection::state, transmit_error_response_static, MHD_Request::url, MHD_Request::url_len, and MHD_Request::version.

Referenced by get_request_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_recv_no_space()

static void handle_recv_no_space ( struct MHD_Connection * c,
enum MHD_ProcRecvDataStage stage )
static

Handle situation with read buffer exhaustion. Must be called when no more space left in the read buffer, no more space left in the memory pool to grow the read buffer, but more data need to be received from the client. Could be called when the result of received data processing cannot be stored in the memory pool (like some header).

Parameters
cthe connection to process
stagethe receive stage where the exhaustion happens.

Definition at line 3407 of file connection.c.

References _, connection_close_error(), MHD_Request::current_chunk_offset, MHD_Request::current_chunk_size, MHD_Connection::daemon, ERR_MSG_REQUEST_TOO_BIG, ERROR_MSG_DATA_NOT_HANDLED_BY_APP, handle_req_chunk_size_line_no_space(), handle_req_footers_no_space(), handle_req_headers_no_space(), has_unprocessed_upload_body_data_in_buffer(), MHD_Request::have_chunked_upload, MHD_Request::http_mthd, MHD_Request::http_ver, mhd_assert, MHD_CONNECTION_BODY_RECEIVING, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_INIT, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_D_IS_USING_THREADS_, MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_MTHD_DELETE, MHD_HTTP_MTHD_GET, MHD_HTTP_MTHD_NO_METHOD, MHD_HTTP_URI_TOO_LONG, MHD_HTTP_VER_UNKNOWN, MHD_PROC_RECV_BODY_CHUNKED, MHD_PROC_RECV_BODY_NORMAL, MHD_PROC_RECV_COOKIE, MHD_PROC_RECV_FOOTERS, MHD_PROC_RECV_HEADERS, MHD_PROC_RECV_HTTPVER, MHD_PROC_RECV_INIT, MHD_PROC_RECV_METHOD, MHD_PROC_RECV_URI, NULL, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::rq, MHD_Request::some_payload_processed, MHD_Connection::state, and transmit_error_response_static.

Referenced by check_and_grow_read_buffer_space().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_req_chunk_size_line_no_space()

static void handle_req_chunk_size_line_no_space ( struct MHD_Connection * c,
const char * chunk_size_line,
size_t chunk_size_line_size )
static

Send error reply when receive buffer space exhausted while receiving the chunk size line.

Parameters
cthe connection to handle
add_headerthe optional pointer to the partially received the current chunk size line. Could be not zero-terminated and can contain binary zeros. Can be NULL.
add_header_sizethe size of the add_header

Definition at line 3342 of file connection.c.

References ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG, ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG, get_no_space_err_status_code(), MHD_HTTP_CONTENT_TOO_LARGE, MHD_PROC_RECV_BODY_CHUNKED, NULL, and transmit_error_response_static.

Referenced by handle_recv_no_space().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_req_footers_no_space()

static void handle_req_footers_no_space ( struct MHD_Connection * c,
const char * add_footer,
size_t add_footer_size )
static

Send error reply when receive buffer space exhausted while receiving or storing the request footers (for chunked requests).

Parameters
cthe connection to handle
add_footerthe optional pointer to the current footer string being processed or the footer failed to be added. Could be not zero-terminated and can contain binary zeros. Can be NULL.
add_footer_sizethe size of the add_footer

Definition at line 3382 of file connection.c.

References ERR_MSG_REQUEST_FOOTER_TOO_BIG, MHD_Request::have_chunked_upload, mhd_assert, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, MHD_Connection::rq, and transmit_error_response_static.

Referenced by get_req_headers(), and handle_recv_no_space().

Here is the caller graph for this function:

◆ handle_req_headers_no_space()

static void handle_req_headers_no_space ( struct MHD_Connection * c,
const char * add_header,
size_t add_header_size )
static

Send error reply when receive buffer space exhausted while receiving or storing the request headers

Parameters
cthe connection to handle
add_headerthe optional pointer to the current header string being processed or the header failed to be added. Could be not zero-terminated and can contain binary zeros. Can be NULL.
add_header_sizethe size of the add_header

Definition at line 3291 of file connection.c.

References ERR_MSG_REQUEST_HEADER_TOO_BIG, get_no_space_err_status_code(), MHD_PROC_RECV_HEADERS, and transmit_error_response_static.

Referenced by get_req_headers(), and handle_recv_no_space().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_unprocessed_upload_body_data_in_buffer()

static bool has_unprocessed_upload_body_data_in_buffer ( struct MHD_Connection * c)
static

Check whether the read buffer has any upload body data ready to be processed. Must be called only when connection is in MHD_CONNECTION_BODY_RECEIVING state.

Parameters
cthe connection to check
Returns
'true' if upload body data is already in the read buffer, 'false' if no upload data is received and not processed.

Definition at line 2960 of file connection.c.

References MHD_Request::current_chunk_offset, MHD_Request::current_chunk_size, MHD_Request::have_chunked_upload, mhd_assert, MHD_CONNECTION_BODY_RECEIVING, MHD_Connection::read_buffer_offset, MHD_Request::remaining_upload_size, MHD_Connection::rq, and MHD_Connection::state.

Referenced by check_and_grow_read_buffer_space(), handle_recv_no_space(), and MHD_connection_update_event_loop_info().

Here is the caller graph for this function:

◆ is_reply_body_needed()

static enum replyBodyUse is_reply_body_needed ( struct MHD_Connection * connection,
unsigned int rcode )
static

Check whether reply body must be used.

If reply body is needed, it could be zero-sized.

Parameters
connectionthe connection to check
rcodethe response code
Returns
enum value indicating whether response body can be used and whether response body length headers are allowed or required.
See also
is_reply_body_header_needed()

< a short alias

Definition at line 2140 of file connection.c.

References MHD_Request::http_mthd, mhd_assert, MHD_HTTP_MTHD_CONNECT, MHD_HTTP_MTHD_HEAD, MHD_HTTP_NO_CONTENT, MHD_HTTP_NOT_MODIFIED, NULL, MHD_Reply::response, MHD_Connection::rp, RP_BODY_HEADERS_ONLY, RP_BODY_NONE, RP_BODY_SEND, and MHD_Connection::rq.

Referenced by MHD_queue_response(), and setup_reply_properties().

Here is the caller graph for this function:

◆ keepalive_possible()

static enum MHD_ConnKeepAlive keepalive_possible ( struct MHD_Connection * connection)
static

Are we allowed to keep the given connection alive? We can use the TCP stream for a second request if the connection is HTTP 1.1 and the "Connection" header either does not exist or is not set to "close", or if the connection is HTTP 1.0 and the "Connection" header is explicitly set to "keep-alive". If no HTTP version is specified (or if it is not 1.0 or 1.1), we definitively close the connection. If the "Connection" header is not exactly "close" or "keep-alive", we proceed to use the default for the respective HTTP version. If response has HTTP/1.0 flag or has "Connection: close" header then connection must be closed. If full request has not been read then connection must be closed as well.

Parameters
connectionthe connection to check for keepalive
Returns
MHD_CONN_USE_KEEPALIVE if (based on the request and the response), a keepalive is legal, MHD_CONN_MUST_CLOSE if connection must be closed after sending complete reply, MHD_CONN_MUST_UPGRADE if connection must be upgraded.

< a short alias

< a short alias

Definition at line 1691 of file connection.c.

References MHD_Connection::discard_request, MHD_Response::flags, MHD_Response::flags_auto, MHD_Request::http_ver, MHD_Connection::keepalive, mhd_assert, MHD_CONN_MUST_CLOSE, MHD_CONN_MUST_UPGRADE, MHD_CONN_USE_KEEPALIVE, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_VER_1_0, MHD_IS_HTTP_VER_1_1_COMPAT, MHD_IS_HTTP_VER_SUPPORTED, MHD_lookup_header_s_token_ci, MHD_RAF_HAS_CONNECTION_CLOSE, MHD_RF_HTTP_1_0_COMPATIBLE_STRICT, MHD_RF_HTTP_1_0_SERVER, NULL, MHD_Connection::read_closed, MHD_Reply::response, MHD_Connection::rp, MHD_Connection::rq, and MHD_Connection::stop_with_error.

Referenced by setup_reply_properties().

Here is the caller graph for this function:

◆ MHD_connection_alloc_memory_()

void * MHD_connection_alloc_memory_ ( struct MHD_Connection * connection,
size_t size )

Allocate memory from connection's memory pool. If memory pool doesn't have enough free memory but read or write buffer have some unused memory, the size of the buffer will be reduced as needed.

Parameters
connectionthe connection to use
sizethe size of allocated memory area
Returns
pointer to allocated memory region in the pool or NULL if no memory is available

< The required amount of additional free memory

Definition at line 651 of file connection.c.

References mhd_assert, MHD_pool_allocate(), MHD_pool_is_resizable_inplace(), MHD_pool_reallocate(), MHD_pool_try_alloc(), NULL, MHD_Connection::pool, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, MHD_Connection::write_buffer_send_offset, and MHD_Connection::write_buffer_size.

Referenced by MHD_set_connection_value_n_nocheck_(), and try_ready_normal_body().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_connection_close_()

void MHD_connection_close_ ( struct MHD_Connection * connection,
enum MHD_RequestTerminationCode termination_code )

Close the given connection and give the specified termination code to the user.

Remarks
To be called only from thread that process connection's recv(), send() and response.
Parameters
connectionconnection to close
termination_codetermination reason to give

Definition at line 1246 of file connection.c.

References MHD_Request::client_aware, MHD_Request::client_context, MHD_Connection::daemon, mhd_assert, MHD_connection_mark_closed_(), MHD_D_IS_USING_THREADS_, MHD_destroy_response(), MHD_pool_destroy(), MHD_thread_handle_ID_is_current_thread_, MHD_Daemon::notify_completed, MHD_Daemon::notify_completed_cls, NULL, MHD_Connection::pool, MHD_Reply::response, MHD_Connection::rp, MHD_Connection::rq, and MHD_Connection::suspended.

Referenced by call_handlers(), close_connection(), connection_close_error(), connection_reset(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_run_tls_handshake_(), and try_ready_normal_body().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_connection_handle_idle()

enum MHD_Result MHD_connection_handle_idle ( struct MHD_Connection * connection)

This function was created to handle per-connection processing that has to happen even if the socket cannot be read or written to. All implementations (multithreaded, external select, internal select) call this function.

Remarks
To be called only from thread that process connection's recv(), send() and response.
Parameters
connectionconnection to handle
Returns
MHD_YES if we should continue to process the connection (not dead yet), MHD_NO if it died

Definition at line 7180 of file connection.c.

References _, build_connection_chunked_response_footer(), build_header_response(), call_connection_handler(), MHD_Reply_Properties::chunked, cleanup_connection(), connection_check_timedout(), CONNECTION_CLOSE_ERROR, connection_reset(), connection_switch_from_recv_to_send(), MHD_Connection::continue_message_write_offset, MHD_Response::crc, MHD_Connection::daemon, MHD_Connection::discard_request, get_req_headers(), get_request_line(), MHD_Request::have_chunked_upload, HTTP_100_CONTINUE, MHD_Request::http_ver, MHD_Connection::in_idle, MHD_Connection::keepalive, mhd_assert, MHD_CONN_USE_KEEPALIVE, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_RECEIVING, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_connection_close_(), MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FULL_REPLY_SENT, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_CONNECTION_HEADERS_SENT, MHD_CONNECTION_INIT, MHD_CONNECTION_NORMAL_BODY_READY, MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_CONNECTION_START_REPLY, MHD_connection_update_event_loop_info(), MHD_D_IS_USING_EPOLL_, MHD_D_IS_USING_THREADS_, MHD_destroy_response(), MHD_FUNC_, MHD_HTTP_PROCESSING, MHD_IS_HTTP_VER_SUPPORTED, MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_NO, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED, MHD_response_execute_upgrade_(), MHD_STATICSTR_LEN_, MHD_thread_handle_ID_is_current_thread_, MHD_TLS_CONN_CONNECTED, MHD_TLS_CONN_INIT, MHD_TLS_CONN_NO_TLS, MHD_YES, need_100_continue(), NULL, MHD_Request::num_cr_sp_replaced, parse_connection_headers(), process_request_body(), MHD_Reply::props, MHD_Connection::read_buffer_offset, MHD_Connection::read_closed, MHD_Request::remaining_upload_size, reset_rq_header_processing_state(), MHD_Reply::response, MHD_Reply::responseCode, MHD_Connection::rp, MHD_Connection::rq, MHD_Reply::rsp_write_position, MHD_Reply_Properties::send_reply_body, MHD_Request::skipped_broken_lines, MHD_Connection::state, MHD_Connection::suspended, switch_to_rq_headers_processing(), MHD_Response::total_size, try_ready_chunked_body(), try_ready_normal_body(), MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_send_offset.

Referenced by call_handlers(), and MHD_queue_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_connection_handle_read()

void MHD_connection_handle_read ( struct MHD_Connection * connection,
bool socket_error )

This function handles a particular connection when it has been determined that there is data to be read off a socket. All implementations (multithreaded, external polling, internal polling) call this function to handle reads.

Parameters
connectionconnection to handle
socket_errorset to true if socket error was detected

Definition at line 6412 of file connection.c.

References _, CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_Connection::discard_request, mhd_assert, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_RECEIVING, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_connection_close_(), MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FULL_REPLY_SENT, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_CONNECTION_HEADERS_SENT, MHD_CONNECTION_INIT, MHD_CONNECTION_NORMAL_BODY_READY, MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_CONNECTION_START_REPLY, MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_FUNC_, MHD_pool_reallocate(), MHD_REQUEST_TERMINATED_CLIENT_ABORT, MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_REQUEST_TERMINATED_READ_ERROR, MHD_REQUEST_TERMINATED_WITH_ERROR, MHD_run_tls_handshake_(), MHD_TLS_CONN_CONNECTED, MHD_TLS_CONN_NO_TLS, MHD_update_last_activity_(), NULL, MHD_Connection::pool, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, MHD_Connection::recv_cls, MHD_Connection::sk_nonblck, MHD_Connection::state, and MHD_Connection::suspended.

Referenced by call_handlers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_connection_handle_write()

void MHD_connection_handle_write ( struct MHD_Connection * connection)

This function was created to handle writes to sockets when it has been determined that the socket can be written to. All implementations (multithreaded, external select, internal select) call this function

Parameters
connectionconnection to handle

Definition at line 6585 of file connection.c.

References _, check_write_done(), MHD_Reply_Properties::chunked, CONNECTION_CLOSE_ERROR, MHD_Connection::continue_message_write_offset, MHD_Response::crc, MHD_Connection::daemon, MHD_Response::data, MHD_Response::data_iov, MHD_Response::data_size, MHD_Response::data_start, HTTP_100_CONTINUE, MHD_Connection::keepalive, mhd_assert, MHD_CONN_MUST_UPGRADE, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_RECEIVING, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FULL_REPLY_SENT, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_CONNECTION_HEADERS_SENT, MHD_CONNECTION_INIT, MHD_CONNECTION_NORMAL_BODY_READY, MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_CONNECTION_START_REPLY, MHD_ERR_AGAIN_, MHD_FUNC_, MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_NO, MHD_PANIC, MHD_run_tls_handshake_(), MHD_send_data_(), MHD_send_hdr_and_body_(), MHD_send_iovec_(), MHD_STATICSTR_LEN_, MHD_TLS_CONN_CONNECTED, MHD_TLS_CONN_NO_TLS, MHD_update_last_activity_(), NULL, MHD_Reply::props, MHD_Reply::resp_iov, MHD_Reply::response, MHD_Connection::rp, MHD_Connection::rq, MHD_Reply::rsp_write_position, MHD_Reply_Properties::send_reply_body, SIZE_MAX, MHD_Connection::state, MHD_Connection::suspended, MHD_Response::total_size, try_ready_normal_body(), MHD_Request::url, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_send_offset.

Referenced by call_handlers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_connection_mark_closed_()

void MHD_connection_mark_closed_ ( struct MHD_Connection * connection)

Mark connection as "closed".

Remarks
To be called from any thread.
Parameters
connectionconnection to close

Definition at line 1208 of file connection.c.

References MHD_Connection::daemon, MHD_Connection::event_loop_info, MHD_CONNECTION_CLOSED, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_tls_connection_shutdown(), MHD_USE_TLS, MHD_USE_TURBO, MHD_Daemon::options, MHD_Daemon::shutdown, MHD_Connection::socket_fd, and MHD_Connection::state.

Referenced by close_connection(), and MHD_connection_close_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_connection_set_initial_state_()

◆ MHD_connection_update_event_loop_info()

static void MHD_connection_update_event_loop_info ( struct MHD_Connection * connection)
static

Update the 'event_loop_info' field of this connection based on the state that the connection is now in. May also close the connection or perform other updates to the connection if needed to prepare for the next round of the event loop.

Parameters
connectionconnection to get poll set for

Definition at line 3707 of file connection.c.

References _, check_and_grow_read_buffer_space(), MHD_Connection::daemon, MHD_Connection::discard_request, MHD_Connection::event_loop_info, has_unprocessed_upload_body_data_in_buffer(), MHD_Request::have_chunked_upload, mhd_assert, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_RECEIVING, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVING, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FULL_REPLY_SENT, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_CONNECTION_HEADERS_SENT, MHD_CONNECTION_INIT, MHD_CONNECTION_NORMAL_BODY_READY, MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_CONNECTION_REQ_LINE_RECEIVED, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_CONNECTION_START_REPLY, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_EVENT_LOOP_INFO_PROCESS, MHD_EVENT_LOOP_INFO_PROCESS_READ, MHD_EVENT_LOOP_INFO_READ, MHD_EVENT_LOOP_INFO_WRITE, MHD_FUNC_, MHD_PANIC, MHD_TLS_CONN_CONNECTED, MHD_TLS_CONN_HANDSHAKING, MHD_TLS_CONN_INIT, MHD_TLS_CONN_INVALID_STATE, MHD_TLS_CONN_NO_TLS, MHD_TLS_CONN_TLS_CLOSED, MHD_TLS_CONN_TLS_CLOSING, MHD_TLS_CONN_TLS_FAILED, MHD_TLS_CONN_WR_CLOSED, MHD_TLS_CONN_WR_CLOSING, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Request::remaining_upload_size, MHD_Connection::rq, MHD_Request::some_payload_processed, MHD_Connection::state, and MHD_Connection::suspended.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_lookup_header_token_ci()

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 )
static

Check whether request header contains particular token.

Token could be surrounded by spaces and tabs and delimited by comma. Case-insensitive match used for header names and tokens.

Parameters
connectionthe connection to get values from
headerthe header name
header_lenthe length of header, not including optional terminating null-character
tokenthe token to find
token_lenthe length of token, not including optional terminating null-character.
Returns
true if token is found in specified header, false otherwise

Definition at line 1122 of file connection.c.

References MHD_HTTP_Req_Header::header, MHD_HTTP_Req_Header::header_size, MHD_Request::headers_received, MHD_HTTP_Req_Header::kind, MHD_HEADER_KIND, MHD_str_equal_caseless_bin_n_(), MHD_str_has_token_caseless_(), MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, and MHD_HTTP_Req_Header::value.

Here is the call graph for this function:

◆ MHD_set_http_callbacks_()

void MHD_set_http_callbacks_ ( struct MHD_Connection * connection)

Set callbacks for this connection to those for HTTP.

Parameters
connectionconnection to initialize

Definition at line 7617 of file connection.c.

References MHD_Connection::recv_cls, and recv_param_adapter().

Referenced by new_connection_prepare_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_update_last_activity_()

void MHD_update_last_activity_ ( struct MHD_Connection * connection)

Update the 'last_activity' field of the connection to the current time and move the connection to the head of the 'normal_timeout' list if the timeout for the connection uses the default value.

Parameters
connectionthe connection that saw some activity

Definition at line 6367 of file connection.c.

References MHD_Connection::connection_timeout_ms, MHD_Daemon::connection_timeout_ms, MHD_Connection::daemon, MHD_Connection::last_activity, mhd_assert, MHD_D_IS_USING_THREAD_PER_CONN_, MHD_monotonic_msec_counter(), MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, NULL, MHD_Connection::suspended, XDLL_insert, and XDLL_remove.

Referenced by MHD_connection_handle_read(), MHD_connection_handle_write(), MHD_queue_response(), and MHD_run_tls_handshake_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ need_100_continue()

static bool need_100_continue ( struct MHD_Connection * connection)
static

Do we (still) need to send a 100 continue message for this connection?

Parameters
connectionconnection to test
Returns
false if we don't need 100 CONTINUE, true if we do

Definition at line 1173 of file connection.c.

References MHD_Request::http_ver, MHD_HEADER_KIND, MHD_HTTP_HEADER_EXPECT, MHD_IS_HTTP_VER_1_1_COMPAT, MHD_lookup_connection_value_n(), MHD_NO, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_(), NULL, MHD_Request::remaining_upload_size, and MHD_Connection::rq.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_connection_headers()

◆ parse_http_std_method()

static void parse_http_std_method ( struct MHD_Connection * connection,
const char * method,
size_t len )
static

Detect standard HTTP request method

Parameters
connectionthe connection
methodthe pointer to HTTP request method string
lenthe length of method in bytes

< short alias

Definition at line 4317 of file connection.c.

References MHD_Request::http_mthd, mhd_assert, MHD_HTTP_METHOD_CONNECT, MHD_HTTP_METHOD_DELETE, MHD_HTTP_METHOD_GET, MHD_HTTP_METHOD_HEAD, MHD_HTTP_METHOD_OPTIONS, MHD_HTTP_METHOD_POST, MHD_HTTP_METHOD_PUT, MHD_HTTP_METHOD_TRACE, MHD_HTTP_MTHD_CONNECT, MHD_HTTP_MTHD_DELETE, MHD_HTTP_MTHD_GET, MHD_HTTP_MTHD_HEAD, MHD_HTTP_MTHD_OPTIONS, MHD_HTTP_MTHD_OTHER, MHD_HTTP_MTHD_POST, MHD_HTTP_MTHD_PUT, MHD_HTTP_MTHD_TRACE, MHD_STATICSTR_LEN_, NULL, and MHD_Connection::rq.

Referenced by get_request_line_inner().

Here is the caller graph for this function:

◆ parse_http_version()

static bool parse_http_version ( struct MHD_Connection * connection,
const char * http_string,
size_t len )
static

Detect HTTP version, send error response if version is not supported

Parameters
connectionthe connection
http_stringthe pointer to HTTP version string
lenthe length of http_string in bytes
Returns
true if HTTP version is correct and supported, false if HTTP version is not correct or unsupported.

< short alias

Definition at line 4256 of file connection.c.

References MHD_Request::http_ver, HTTP_VER_LEN, mhd_assert, MHD_HTTP_BAD_REQUEST, MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED, MHD_HTTP_VER_1_0, MHD_HTTP_VER_1_1, MHD_HTTP_VER_1_2__1_9, MHD_HTTP_VER_FUTURE, MHD_HTTP_VER_INVALID, MHD_HTTP_VER_TOO_OLD, NULL, REQ_HTTP_VER_IS_NOT_SUPPORTED, REQ_HTTP_VER_IS_TOO_OLD, REQUEST_MALFORMED, MHD_Connection::rq, and transmit_error_response_static.

Referenced by get_request_line_inner().

Here is the caller graph for this function:

◆ process_request_body()

static void process_request_body ( struct MHD_Connection * connection)
static

◆ process_request_target()

static bool process_request_target ( struct MHD_Connection * c)
static

◆ recv_param_adapter()

static ssize_t recv_param_adapter ( struct MHD_Connection * connection,
void * other,
size_t i )
static

Callback for receiving data from the socket.

Parameters
connectionthe MHD connection structure
otherwhere to write received data to
imaximum size of other (in bytes)
Returns
positive value for number of bytes actually received or negative value for error number MHD_ERR_xxx_

Definition at line 725 of file connection.c.

References MHD_CONNECTION_CLOSED, MHD_EPOLL_STATE_READ_READY, MHD_ERR_AGAIN_, MHD_ERR_BADF_, MHD_ERR_CONNRESET_, MHD_ERR_INVAL_, MHD_ERR_NOMEM_, MHD_ERR_NOTCONN_, MHD_ERR_OPNOTSUPP_, MHD_INVALID_SOCKET, MHD_recv_, MHD_SCKT_EBADF_, MHD_SCKT_EINVAL_, MHD_SCKT_ENOTCONN_, MHD_SCKT_EOPNOTSUPP_, MHD_SCKT_ERR_IS_, MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_EINTR_, MHD_SCKT_ERR_IS_LOW_RESOURCES_, MHD_SCKT_ERR_IS_REMOTE_DISCNN_, MHD_SCKT_SEND_MAX_SIZE_, MHD_socket_get_error_, MHD_Connection::socket_fd, and MHD_Connection::state.

Referenced by MHD_set_http_callbacks_().

Here is the caller graph for this function:

◆ reset_rq_header_processing_state()

_MHD_static_inline void reset_rq_header_processing_state ( struct MHD_Connection * c)

Reset request header processing state.

This function resets the processing state before processing the next header (or footer) line.

Parameters
cthe connection to process

Definition at line 4862 of file connection.c.

References MHD_HeadersProcessing::hdr, MHD_Request::hdrs, and MHD_Connection::rq.

Referenced by get_req_headers(), and MHD_connection_handle_idle().

Here is the caller graph for this function:

◆ send_redirect_fixed_rq_target()

static void send_redirect_fixed_rq_target ( struct MHD_Connection * c)
static

Send the automatic redirection to fixed URI when received URI with whitespaces. If URI is too large, close connection with error.

Parameters
cthe connection to process

Definition at line 5457 of file connection.c.

References _, connection_close_error(), MHD_Connection::daemon, MHD_Request::hdrs, mhd_assert, MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_HTTP_HEADER_LOCATION, MHD_HTTP_MOVED_PERMANENTLY, MHD_MAX_FIXED_URI_LEN, MHD_STATICSTR_LEN_, NULL, MHD_RequestLineProcessing::num_ws_in_uri, MHD_Daemon::pool_size, MHD_Request::req_target_len, MHD_Connection::rq, MHD_HeadersProcessing::rq_line, RQ_TARGET_INVALID_CHAR, MHD_RequestLineProcessing::rq_tgt, MHD_Connection::state, and transmit_error_response_header.

Referenced by get_request_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_reply_properties()

static void setup_reply_properties ( struct MHD_Connection * connection)
static

Setup connection reply properties.

Reply properties include presence of reply body, transfer-encoding type and other.

Parameters
connectionto connection to process

< a short alias

< a short alias

Definition at line 2196 of file connection.c.

References MHD_Reply_Properties::chunked, MHD_Response::flags, MHD_Response::flags_auto, MHD_Request::http_ver, is_reply_body_needed(), MHD_Connection::keepalive, keepalive_possible(), mhd_assert, MHD_CONN_MUST_CLOSE, MHD_IS_HTTP_VER_1_1_COMPAT, MHD_RAF_HAS_TRANS_ENC_CHUNKED, MHD_RF_HTTP_1_0_COMPATIBLE_STRICT, MHD_RF_HTTP_1_0_SERVER, MHD_SIZE_UNKNOWN, NULL, MHD_Reply::props, MHD_Reply::response, MHD_Reply::responseCode, MHD_Connection::rp, RP_BODY_HEADERS_ONLY, RP_BODY_NONE, MHD_Connection::rq, MHD_Reply_Properties::send_reply_body, MHD_Response::total_size, and MHD_Reply_Properties::use_reply_body_headers.

Referenced by build_header_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switch_to_rq_headers_processing()

_MHD_static_inline void switch_to_rq_headers_processing ( struct MHD_Connection * c)

Switch to request headers (field lines) processing state.

Parameters
cthe connection to process

Definition at line 4873 of file connection.c.

References MHD_Request::field_lines, MHD_HeadersProcessing::hdr, MHD_Request::hdrs, MHD_CONNECTION_REQ_HEADERS_RECEIVING, MHD_Connection::read_buffer, MHD_Connection::rq, MHD_StartOrSize::start, and MHD_Connection::state.

Referenced by MHD_connection_handle_idle().

Here is the caller graph for this function:

◆ transmit_error_response_len()

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 )
static

We encountered an error processing the request. Handle it properly by stopping to read data and sending the indicated response code and message.

Parameters
connectionthe connection
status_codethe response code to send (400, 413 or 414)
messagethe error message to send
message_lenthe length of the message
header_namethe name of the header, malloc()ed by the caller, free() by this function, optional, can be NULL
header_name_lenthe length of the header_name
header_valuethe value of the header, malloc()ed by the caller, free() by this function, optional, can be NULL
header_value_lenthe length of the header_value

Definition at line 2775 of file connection.c.

References _, build_header_response(), CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_Connection::discard_request, MHD_Request::headers_received, MHD_Request::headers_received_tail, MHD_Connection::in_access_handler, MHD_Connection::keepalive, MHD_Request::method, MHD_add_response_entry_no_alloc_(), mhd_assert, MHD_CONN_MUST_CLOSE, MHD_CONNECTION_CLOSED, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_CONNECTION_START_REPLY, MHD_create_response_from_buffer_static(), MHD_destroy_response(), MHD_HEADER_KIND, MHD_NO, MHD_pool_deallocate(), MHD_pool_reset(), MHD_queue_response(), MHD_YES, NULL, MHD_Connection::pool, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Reply::response, MHD_Connection::rp, MHD_Connection::rq, MHD_Connection::state, MHD_Connection::stop_with_error, MHD_Request::url, MHD_Request::url_len, MHD_Request::version, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, MHD_Connection::write_buffer_send_offset, and MHD_Connection::write_buffer_size.

Here is the call graph for this function:

◆ try_grow_read_buffer()

static bool try_grow_read_buffer ( struct MHD_Connection * connection,
bool required )
static

Try growing the read buffer. We initially claim half the available buffer space for the read buffer (the other half being left for management data structures; the write buffer can in the end take virtually everything as the read buffer can be reduced to the minimum necessary at that point.

Parameters
connectionthe connection
requiredset to 'true' if grow is required, i.e. connection will fail if no additional space is granted
Returns
'true' on success, 'false' on failure

Definition at line 1877 of file connection.c.

References MHD_Connection::daemon, mhd_assert, MHD_BUF_INC_SIZE, MHD_pool_get_free(), MHD_pool_is_resizable_inplace(), MHD_pool_reallocate(), NULL, MHD_Connection::pool, MHD_Daemon::pool_increment, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, and MHD_Connection::read_buffer_size.

Referenced by check_and_grow_read_buffer_space().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_ready_chunked_body()

static enum MHD_Result try_ready_chunked_body ( struct MHD_Connection * connection,
bool * p_finished )
static

Prepare the response buffer of this connection for sending. Assumes that the response mutex is already held. If the transmission is complete, this function may close the socket (and return MHD_NO).

Parameters
connectionthe connection
[out]p_finishedthe pointer to variable that will be set to "true" when application returned indication of the end of the stream
Returns
MHD_NO if readying the response failed

Definition at line 1505 of file connection.c.

References _, CONNECTION_CLOSE_ERROR, MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::data, MHD_Response::data_size, MHD_Response::data_start, mhd_assert, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONTENT_READER_END_OF_STREAM, MHD_CONTENT_READER_END_WITH_ERROR, MHD_mutex_unlock_chk_, MHD_NO, MHD_pool_get_free(), MHD_pool_is_resizable_inplace(), MHD_pool_reallocate(), MHD_SIZE_UNKNOWN, MHD_uint32_to_strx(), MHD_YES, NULL, MHD_Connection::pool, MHD_Reply::response, MHD_Connection::rp, MHD_Reply::rsp_write_position, SSIZE_MAX, MHD_Connection::state, MHD_Response::total_size, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, MHD_Connection::write_buffer_send_offset, and MHD_Connection::write_buffer_size.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_ready_normal_body()

static enum MHD_Result try_ready_normal_body ( struct MHD_Connection * connection)
static

Prepare the response buffer of this connection for sending. Assumes that the response mutex is already held. If the transmission is complete, this function may close the socket (and return MHD_NO).

Parameters
connectionthe connection
Returns
MHD_NO if readying the response failed (the lock on the response will have been released already in this case).

Definition at line 1403 of file connection.c.

References _, MHD_iovec_track_::cnt, CONNECTION_CLOSE_ERROR, MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::data, MHD_Response::data_buffer_size, MHD_Response::data_iov, MHD_Response::data_iovcnt, MHD_Response::data_size, MHD_Response::data_start, MHD_iovec_track_::iov, mhd_assert, MHD_connection_alloc_memory_(), MHD_connection_close_(), MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONTENT_READER_END_OF_STREAM, MHD_MIN, MHD_mutex_unlock_chk_, MHD_NO, MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_YES, NULL, MHD_Reply::props, MHD_Reply::resp_iov, MHD_Reply::response, MHD_Connection::rp, MHD_Reply::rsp_write_position, MHD_Reply_Properties::send_reply_body, MHD_iovec_track_::sent, MHD_Connection::state, and MHD_Response::total_size.

Referenced by MHD_connection_handle_idle(), and MHD_connection_handle_write().

Here is the call graph for this function:
Here is the caller graph for this function: