GNU libmicrohttpd
0.9.29
|
Methods for managing connections. More...
#include "internal.h"
#include <limits.h>
#include "connection.h"
#include "memorypool.h"
#include "response.h"
#include "reason_phrase.h"
Go to the source code of this file.
Macros | |
#define | HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" |
#define | REQUEST_TOO_BIG "" |
#define | REQUEST_LACKS_HOST "" |
#define | REQUEST_MALFORMED "" |
#define | INTERNAL_ERROR "" |
#define | DEBUG_CLOSE MHD_NO |
#define | DEBUG_SEND_DATA MHD_NO |
#define | CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, NULL) |
Functions | |
int | MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) |
int | MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) |
const char * | MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key) |
static int | need_100_continue (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 int | try_ready_normal_body (struct MHD_Connection *connection) |
static int | try_ready_chunked_body (struct MHD_Connection *connection) |
static void | add_extra_headers (struct MHD_Connection *connection) |
static void | get_date_string (char *date) |
static int | try_grow_read_buffer (struct MHD_Connection *connection) |
static int | build_header_response (struct MHD_Connection *connection) |
static void | transmit_error_response (struct MHD_Connection *connection, unsigned int status_code, const char *message) |
static void | MHD_connection_update_event_loop_info (struct MHD_Connection *connection) |
static char * | get_next_header_line (struct MHD_Connection *connection) |
static int | connection_add_header (struct MHD_Connection *connection, char *key, char *value, enum MHD_ValueKind kind) |
static int | parse_arguments (enum MHD_ValueKind kind, struct MHD_Connection *connection, char *args) |
static int | parse_cookie_header (struct MHD_Connection *connection) |
static int | parse_initial_message_line (struct MHD_Connection *connection, char *line) |
static void | call_connection_handler (struct MHD_Connection *connection) |
static void | process_request_body (struct MHD_Connection *connection) |
static int | do_read (struct MHD_Connection *connection) |
static int | do_write (struct MHD_Connection *connection) |
static int | check_write_done (struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state) |
static int | process_header_line (struct MHD_Connection *connection, char *line) |
static int | process_broken_line (struct MHD_Connection *connection, char *line, enum MHD_ValueKind kind) |
static void | parse_connection_headers (struct MHD_Connection *connection) |
static void | update_last_activity (struct MHD_Connection *connection) |
int | MHD_connection_handle_read (struct MHD_Connection *connection) |
int | MHD_connection_handle_write (struct MHD_Connection *connection) |
static void | cleanup_connection (struct MHD_Connection *connection) |
int | MHD_connection_handle_idle (struct MHD_Connection *connection) |
void | MHD_set_http_callbacks_ (struct MHD_Connection *connection) |
union MHD_ConnectionInfo * | MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type,...) |
int | MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option,...) |
int | MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response) |
Methods for managing connections.
Definition in file connection.c.
#define CONNECTION_CLOSE_ERROR | ( | c, | |
emsg | |||
) | connection_close_error (c, NULL) |
Macro to only include error message in call to "connection_close_error" if we have HAVE_MESSAGES.
Definition at line 308 of file connection.c.
Referenced by call_connection_handler(), do_read(), do_write(), MHD_connection_handle_idle(), MHD_connection_handle_write(), MHD_connection_update_event_loop_info(), parse_connection_headers(), process_header_line(), process_request_body(), transmit_error_response(), try_ready_chunked_body(), and try_ready_normal_body().
#define DEBUG_CLOSE MHD_NO |
Add extra debug messages with reasons for closing connections (non-error reasons).
Definition at line 101 of file connection.c.
#define DEBUG_SEND_DATA MHD_NO |
Should all data send be printed to stderr?
Definition at line 106 of file connection.c.
#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 44 of file connection.c.
Referenced by MHD_connection_handle_idle(), MHD_connection_handle_write(), and need_100_continue().
#define INTERNAL_ERROR "" |
Response text used when there is an internal server error.
Intentionally empty here to keep our memory footprint minimal.
Definition at line 94 of file connection.c.
Referenced by MHD_connection_update_event_loop_info().
#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 69 of file connection.c.
Referenced by parse_connection_headers().
#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 82 of file connection.c.
Referenced by MHD_connection_handle_idle(), and process_broken_line().
#define REQUEST_TOO_BIG "" |
Response text used when the request (http header) is too big to be processed.
Intentionally empty here to keep our memory footprint minimal.
Definition at line 56 of file connection.c.
Referenced by connection_add_header(), get_next_header_line(), MHD_connection_update_event_loop_info(), parse_cookie_header(), and process_broken_line().
|
static |
Check if we need to set some additional headers for http-compiliance.
connection | connection to check (and possibly modify) |
Definition at line 493 of file connection.c.
References MHD_Connection::have_chunked_upload, MHD_Connection::method, MHD_add_response_header(), MHD_get_response_header(), MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_HTTP_HEADER_TRANSFER_ENCODING, MHD_HTTP_METHOD_CONNECT, MHD_HTTP_VERSION_1_1, MHD_lookup_connection_value(), MHD_NO, MHD_SIZE_UNKNOWN, MHD_UNSIGNED_LONG_LONG, MHD_UNSIGNED_LONG_LONG_PRINTF, MHD_YES, NULL, MHD_Connection::response, MHD_Response::total_size, and MHD_Connection::version.
Referenced by build_header_response().
|
static |
Allocate the connection's write buffer and fill it with all of the headers (or footers, if we have already sent the body) from the HTTPd's response.
connection | the connection |
Definition at line 660 of file connection.c.
References add_extra_headers(), MHD_Connection::daemon, EXTRA_CHECK, MHD_Response::first_header, get_date_string(), MHD_HTTP_Header::header, MHD_HTTP_Header::kind, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_FOOTER_KIND, MHD_get_reason_phrase_for(), MHD_get_response_header(), MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_DATE, MHD_HTTP_VERSION_1_0, MHD_HTTP_VERSION_1_1, MHD_ICY_FLAG, MHD_NO, mhd_panic, mhd_panic_cls, MHD_pool_allocate(), MHD_SUPPRESS_DATE_NO_CLOCK, MHD_YES, MHD_HTTP_Header::next, NULL, MHD_Daemon::options, MHD_Connection::pool, MHD_Connection::read_closed, MHD_Connection::response, MHD_Connection::responseCode, MHD_Connection::state, MHD_HTTP_Header::value, MHD_Connection::version, 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(), and transmit_error_response().
|
static |
Call the handler of the application for this connection. Handles chunking of the upload as well as normal uploads.
connection | connection we're processing |
Definition at line 1286 of file connection.c.
References MHD_Connection::client_aware, MHD_Connection::client_context, CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_Daemon::default_handler, MHD_Connection::method, MHD_NO, MHD_YES, NULL, MHD_Connection::response, MHD_Connection::url, and MHD_Connection::version.
Referenced by MHD_connection_handle_idle().
|
static |
Check if we are done sending the write-buffer. If so, transition into "next_state".
connection | connection to check write status for |
next_state | the next state to transition to |
Definition at line 1603 of file connection.c.
References MHD_NO, MHD_pool_reallocate(), MHD_YES, NULL, MHD_Connection::pool, MHD_Connection::state, 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_write().
|
static |
Clean up the state of the given connection and move it into the clean up queue for final disposal.
connection | handle for the connection to clean up |
Definition at line 2067 of file connection.c.
References MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::cleanup_head, MHD_Daemon::cleanup_tail, MHD_Connection::connection_timeout, MHD_Daemon::connection_timeout, MHD_Daemon::connections_head, MHD_Daemon::connections_tail, MHD_Connection::daemon, DLL_insert, DLL_remove, MHD_Connection::in_idle, MHD_Daemon::manual_timeout_head, MHD_Daemon::manual_timeout_tail, MHD_destroy_response(), MHD_NO, MHD_PANIC, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, NULL, MHD_Daemon::options, MHD_Connection::response, MHD_Connection::resuming, MHD_Connection::suspended, MHD_Daemon::suspended_connections_head, MHD_Daemon::suspended_connections_tail, and XDLL_remove.
Referenced by MHD_connection_handle_idle().
|
static |
Add an entry to the HTTP headers of a connection. If this fails, transmit an error response (request too big).
connection | the connection for which a value should be set |
kind | kind of the value |
key | key for the value |
value | the value itself |
Definition at line 1029 of file connection.c.
References MHD_Connection::daemon, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_NO, MHD_set_connection_value(), MHD_YES, REQUEST_TOO_BIG, and transmit_error_response().
Referenced by parse_arguments(), parse_cookie_header(), and process_broken_line().
|
static |
A serious error occured, close the connection (and notify the application).
connection | connection to close with error |
emsg | error message (can be NULL) |
Definition at line 290 of file connection.c.
References MHD_Connection::daemon, MHD_connection_close(), MHD_REQUEST_TERMINATED_WITH_ERROR, and NULL.
|
static |
Try reading data from the socket into the read buffer of the connection.
connection | connection we're processing |
Definition at line 1500 of file connection.c.
References CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_connection_close(), MHD_NO, MHD_REQUEST_TERMINATED_CLIENT_ABORT, MHD_USE_SSL, MHD_YES, NULL, MHD_Daemon::options, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, and MHD_Connection::recv_cls.
Referenced by MHD_connection_handle_read().
|
static |
Try writing data to the socket from the write buffer of the connection.
connection | connection we're processing |
Definition at line 1551 of file connection.c.
References CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_NO, MHD_USE_SSL, MHD_YES, NULL, MHD_Daemon::options, MHD_Connection::send_cls, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_send_offset.
Referenced by MHD_connection_handle_write().
|
static |
Produce HTTP "Date:" header.
date | where to write the header, with at least 128 bytes available space. |
Definition at line 592 of file connection.c.
Referenced by build_header_response().
|
static |
Parse a single line of the HTTP header. Advance read_buffer (!) appropriately. If the current line does not fit, consider growing the buffer. If the line is far too long, close the connection. If no line is found (incomplete, buffer too small, line too long), return NULL. Otherwise return a pointer to the line.
connection | connection we're processing |
Definition at line 978 of file connection.c.
References MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_HTTP_REQUEST_URI_TOO_LONG, MHD_NO, NULL, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, REQUEST_TOO_BIG, transmit_error_response(), try_grow_read_buffer(), and MHD_Connection::url.
Referenced by MHD_connection_handle_idle().
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.
connection | connection to close |
termination_code | termination reason to give |
Definition at line 261 of file connection.c.
References MHD_Connection::client_aware, MHD_Connection::client_context, MHD_Connection::daemon, MHD_Connection::event_loop_info, MHD_CONNECTION_CLOSED, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_NO, MHD_USE_EPOLL_TURBO, MHD_YES, MHD_Daemon::notify_completed, MHD_Daemon::notify_completed_cls, NULL, MHD_Daemon::options, MHD_Connection::read_closed, MHD_Connection::socket_fd, and MHD_Connection::state.
Referenced by close_connection(), connection_close_error(), do_read(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_handle_connection(), MHD_tls_connection_handle_idle(), run_tls_handshake(), and try_ready_normal_body().
int 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.
connection | connection to handle |
Definition at line 2116 of file connection.c.
References build_header_response(), call_connection_handler(), cleanup_connection(), MHD_Connection::client_aware, MHD_Connection::client_context, CONNECTION_CLOSE_ERROR, MHD_Connection::connection_timeout, MHD_Connection::continue_message_write_offset, MHD_Response::crc, MHD_Connection::daemon, EDLL_insert, MHD_Connection::event_loop_info, EXTRA_CHECK, get_next_header_line(), MHD_Connection::have_chunked_upload, MHD_Connection::headers_received, MHD_Connection::headers_received_tail, HTTP_100_CONTINUE, MHD_Connection::in_idle, MHD_Connection::last_activity, MHD_Connection::method, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_connection_close(), MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_CONTINUE_SENT, MHD_CONNECTION_FOOTER_PART_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FOOTERS_SENT, MHD_CONNECTION_HEADER_PART_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_update_event_loop_info(), MHD_CONNECTION_URL_RECEIVED, MHD_destroy_response(), MHD_EPOLL_STATE_IN_EREADY_EDLL, MHD_EPOLL_STATE_READ_READY, MHD_EPOLL_STATE_SUSPENDED, MHD_EPOLL_STATE_WRITE_READY, MHD_EVENT_LOOP_INFO_BLOCK, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_EVENT_LOOP_INFO_READ, MHD_EVENT_LOOP_INFO_WRITE, MHD_FOOTER_KIND, MHD_get_response_header(), MHD_HEADER_KIND, MHD_HTTP_BAD_REQUEST, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_METHOD_POST, MHD_HTTP_METHOD_PUT, MHD_HTTP_VERSION_1_1, MHD_lookup_connection_value(), MHD_monotonic_time(), MHD_NO, MHD_pool_destroy(), MHD_pool_reset(), MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED, MHD_SIZE_UNKNOWN, MHD_YES, MHD_Response::mutex, need_100_continue(), MHD_Daemon::notify_completed, MHD_Daemon::notify_completed_cls, NULL, parse_connection_headers(), parse_initial_message_line(), MHD_Connection::pool, process_broken_line(), process_header_line(), process_request_body(), MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, MHD_Connection::remaining_upload_size, REQUEST_MALFORMED, MHD_Connection::response, MHD_Connection::response_write_position, MHD_Connection::responseCode, MHD_Connection::socket_fd, MHD_Connection::state, MHD_Response::total_size, transmit_error_response(), try_ready_chunked_body(), try_ready_normal_body(), MHD_Connection::url, MHD_Connection::version, 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_queue_response(), MHD_set_http_callbacks_(), and MHD_tls_connection_handle_idle().
int MHD_connection_handle_read | ( | struct MHD_Connection * | connection | ) |
This function handles a particular connection when it has been determined that there is data to be read off a socket.
connection | connection to handle |
Definition at line 1854 of file connection.c.
References MHD_Connection::daemon, do_read(), MHD_CONNECTION_BODY_RECEIVED, MHD_connection_close(), MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_CONTINUE_SENT, MHD_CONNECTION_FOOTER_PART_RECEIVED, MHD_CONNECTION_HEADER_PART_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_CONNECTION_HEADERS_RECEIVED, MHD_CONNECTION_INIT, MHD_CONNECTION_URL_RECEIVED, MHD_NO, MHD_pool_reallocate(), MHD_REQUEST_TERMINATED_READ_ERROR, MHD_YES, MHD_Connection::pool, MHD_Daemon::pool_increment, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, MHD_Connection::state, try_grow_read_buffer(), and update_last_activity().
Referenced by MHD_set_http_callbacks_(), and MHD_tls_connection_handle_read().
int 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.
connection | connection to handle |
Definition at line 1916 of file connection.c.
References check_write_done(), CONNECTION_CLOSE_ERROR, MHD_Connection::continue_message_write_offset, MHD_Response::crc, MHD_Connection::daemon, MHD_Response::data, MHD_Response::data_size, MHD_Response::data_start, do_write(), EXTRA_CHECK, HTTP_100_CONTINUE, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_CONTINUE_SENT, MHD_CONNECTION_FOOTER_PART_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FOOTERS_SENT, MHD_CONNECTION_HEADER_PART_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_URL_RECEIVED, MHD_TLS_CONNECTION_INIT, MHD_YES, MHD_Response::mutex, NULL, MHD_Connection::response, MHD_Connection::response_write_position, MHD_Connection::send_cls, MHD_Connection::state, MHD_Response::total_size, try_ready_normal_body(), and update_last_activity().
Referenced by MHD_set_http_callbacks_(), and MHD_tls_connection_handle_write().
|
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.
connection | connetion to get poll set for |
Definition at line 832 of file connection.c.
References CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, MHD_Connection::event_loop_info, EXTRA_CHECK, INTERNAL_ERROR, MHD_CONNECTION_BODY_RECEIVED, MHD_CONNECTION_BODY_SENT, MHD_CONNECTION_CHUNKED_BODY_READY, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONNECTION_CLOSED, MHD_CONNECTION_CONTINUE_SENDING, MHD_CONNECTION_CONTINUE_SENT, MHD_CONNECTION_FOOTER_PART_RECEIVED, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_FOOTERS_SENDING, MHD_CONNECTION_FOOTERS_SENT, MHD_CONNECTION_HEADER_PART_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_URL_RECEIVED, MHD_EVENT_LOOP_INFO_BLOCK, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_EVENT_LOOP_INFO_READ, MHD_EVENT_LOOP_INFO_WRITE, MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_HTTP_REQUEST_URI_TOO_LONG, MHD_NO, MHD_TLS_CONNECTION_INIT, MHD_USE_SELECT_INTERNALLY, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Daemon::options, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, REQUEST_TOO_BIG, MHD_Connection::state, transmit_error_response(), try_grow_read_buffer(), and MHD_Connection::url.
Referenced by MHD_connection_handle_idle().
void MHD_set_http_callbacks_ | ( | struct MHD_Connection * | connection | ) |
Set callbacks for this connection to those for HTTP.
connection | connection to initialize |
Definition at line 2599 of file connection.c.
References MHD_Connection::idle_handler, MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_connection_handle_write(), MHD_Connection::read_handler, and MHD_Connection::write_handler.
Referenced by internal_add_connection().
|
static |
Do we (still) need to send a 100 continue message for this connection?
connection | connection to test |
Definition at line 236 of file connection.c.
References MHD_Connection::continue_message_write_offset, HTTP_100_CONTINUE, MHD_HEADER_KIND, MHD_HTTP_HEADER_EXPECT, MHD_HTTP_VERSION_1_1, MHD_lookup_connection_value(), NULL, MHD_Connection::response, and MHD_Connection::version.
Referenced by MHD_connection_handle_idle().
|
static |
Parse and unescape the arguments given by the client as part of the HTTP request URI.
kind | header kind to use for adding to the connection |
connection | connection to add headers to |
args | argument URI string (after "?" in URI) |
Definition at line 1058 of file connection.c.
References connection_add_header(), MHD_Connection::daemon, MHD_NO, MHD_YES, NULL, MHD_Daemon::unescape_callback, and MHD_Daemon::unescape_callback_cls.
Referenced by parse_initial_message_line().
|
static |
Parse the various headers; figure out the size of the upload and make sure the headers follow the protocol. Advance to the appropriate state.
connection | connection we're processing |
Definition at line 1744 of file connection.c.
References CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, EXTRA_CHECK, MHD_Connection::have_chunked_upload, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_create_response_from_buffer(), MHD_destroy_response(), MHD_HEADER_KIND, MHD_HTTP_BAD_REQUEST, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_HTTP_HEADER_HOST, MHD_HTTP_HEADER_TRANSFER_ENCODING, MHD_HTTP_VERSION_1_1, MHD_lookup_connection_value(), MHD_queue_response(), MHD_RESPMEM_PERSISTENT, MHD_SIZE_UNKNOWN, MHD_UNSIGNED_LONG_LONG, MHD_USE_PEDANTIC_CHECKS, MHD_YES, NULL, MHD_Daemon::options, parse_cookie_header(), MHD_Connection::read_closed, MHD_Connection::remaining_upload_size, REQUEST_LACKS_HOST, MHD_Connection::response, MHD_Connection::state, and MHD_Connection::version.
Referenced by MHD_connection_handle_idle().
|
static |
Parse the cookie header (see RFC 2109).
Definition at line 1139 of file connection.c.
References connection_add_header(), MHD_Connection::daemon, MHD_COOKIE_KIND, MHD_HEADER_KIND, MHD_HTTP_HEADER_COOKIE, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_lookup_connection_value(), MHD_NO, MHD_pool_allocate(), MHD_YES, NULL, MHD_Connection::pool, REQUEST_TOO_BIG, and transmit_error_response().
Referenced by parse_connection_headers().
|
static |
Parse the first line of the HTTP HEADER.
connection | the connection (updated) |
line | the first line |
Definition at line 1235 of file connection.c.
References MHD_Connection::client_context, MHD_Connection::daemon, MHD_Connection::method, MHD_GET_ARGUMENT_KIND, MHD_NO, MHD_YES, NULL, parse_arguments(), MHD_Daemon::unescape_callback, MHD_Daemon::unescape_callback_cls, MHD_Daemon::uri_log_callback, MHD_Daemon::uri_log_callback_cls, MHD_Connection::url, and MHD_Connection::version.
Referenced by MHD_connection_handle_idle().
|
static |
Process a header value that spans multiple lines. The previous line(s) are in connection->last.
connection | connection we're processing |
line | the current input line |
kind | if the line is complete, add a header of the given kind |
Definition at line 1671 of file connection.c.
References MHD_Connection::colon, connection_add_header(), EXTRA_CHECK, MHD_Connection::last, MHD_HTTP_BAD_REQUEST, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_NO, MHD_pool_reallocate(), MHD_YES, NULL, MHD_Connection::pool, process_header_line(), REQUEST_MALFORMED, REQUEST_TOO_BIG, and transmit_error_response().
Referenced by MHD_connection_handle_idle().
|
static |
We have received (possibly the beginning of) a line in the header (or footer). Validate (check for ":") and prepare to process.
connection | connection we're processing |
line | line from the header to process |
Definition at line 1631 of file connection.c.
References MHD_Connection::colon, CONNECTION_CLOSE_ERROR, MHD_Connection::last, MHD_NO, MHD_YES, and NULL.
Referenced by MHD_connection_handle_idle(), and process_broken_line().
|
static |
Call the handler of the application for this connection. Handles chunking of the upload as well as normal uploads.
connection | connection we're processing |
Definition at line 1320 of file connection.c.
References MHD_Connection::client_aware, MHD_Connection::client_context, CONNECTION_CLOSE_ERROR, MHD_Connection::current_chunk_offset, MHD_Connection::current_chunk_size, MHD_Connection::daemon, MHD_Daemon::default_handler, MHD_Connection::have_chunked_upload, MHD_Connection::method, MHD_NO, mhd_panic, mhd_panic_cls, MHD_SIZE_UNKNOWN, MHD_YES, NULL, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::remaining_upload_size, MHD_Connection::response, MHD_Connection::url, and MHD_Connection::version.
Referenced by MHD_connection_handle_idle().
|
static |
We encountered an error processing the request. Handle it properly by stopping to read data and sending the indicated response code and message.
connection | the connection |
status_code | the response code to send (400, 413 or 414) |
message | the error message to send |
Definition at line 784 of file connection.c.
References build_header_response(), CONNECTION_CLOSE_ERROR, MHD_Connection::daemon, EXTRA_CHECK, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_HEADERS_SENDING, MHD_create_response_from_buffer(), MHD_destroy_response(), MHD_HTTP_VERSION_1_0, MHD_NO, MHD_queue_response(), MHD_RESPMEM_PERSISTENT, MHD_YES, NULL, MHD_Connection::read_closed, MHD_Connection::response, MHD_Connection::state, and MHD_Connection::version.
Referenced by connection_add_header(), get_next_header_line(), MHD_connection_handle_idle(), MHD_connection_update_event_loop_info(), parse_cookie_header(), and process_broken_line().
|
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.
connection | the connection |
Definition at line 629 of file connection.c.
References MHD_Connection::daemon, MHD_BUF_INC_SIZE, MHD_NO, MHD_pool_reallocate(), MHD_YES, NULL, MHD_Connection::pool, MHD_Daemon::pool_size, MHD_Connection::read_buffer, and MHD_Connection::read_buffer_size.
Referenced by get_next_header_line(), MHD_connection_handle_read(), and MHD_connection_update_event_loop_info().
|
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).
connection | the connection |
Definition at line 392 of file connection.c.
References CONNECTION_CLOSE_ERROR, MHD_Response::crc, MHD_Response::crc_cls, MHD_Connection::daemon, MHD_Response::data, MHD_Response::data_size, MHD_Response::data_start, EXTRA_CHECK, MHD_CONNECTION_CHUNKED_BODY_UNREADY, MHD_CONTENT_READER_END_OF_STREAM, MHD_CONTENT_READER_END_WITH_ERROR, MHD_NO, MHD_pool_allocate(), MHD_YES, NULL, MHD_Connection::pool, MHD_Daemon::pool_size, MHD_Connection::response, MHD_Connection::response_write_position, 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().
|
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).
connection | the connection |
Definition at line 325 of file connection.c.
References CONNECTION_CLOSE_ERROR, MHD_Response::crc, MHD_Response::crc_cls, MHD_Connection::daemon, MHD_Response::data, MHD_Response::data_buffer_size, MHD_Response::data_size, MHD_Response::data_start, MHD_Response::fd, MHD_connection_close(), MHD_CONNECTION_NORMAL_BODY_UNREADY, MHD_CONTENT_READER_END_OF_STREAM, MHD_CONTENT_READER_END_WITH_ERROR, MHD_MIN, MHD_NO, MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_USE_SSL, MHD_YES, MHD_Response::mutex, NULL, MHD_Daemon::options, MHD_Connection::response, MHD_Connection::response_write_position, MHD_Connection::state, and MHD_Response::total_size.
Referenced by MHD_connection_handle_idle(), and MHD_connection_handle_write().
|
static |
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.
connection | the connection that saw some activity |
Definition at line 1821 of file connection.c.
References MHD_Daemon::cleanup_connection_mutex, MHD_Connection::connection_timeout, MHD_Daemon::connection_timeout, MHD_Connection::daemon, MHD_Connection::last_activity, MHD_monotonic_time(), MHD_PANIC, MHD_USE_THREAD_PER_CONNECTION, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, MHD_Daemon::options, XDLL_insert, and XDLL_remove.
Referenced by MHD_connection_handle_read(), and MHD_connection_handle_write().