GNU libmicrohttpd  0.9.72
MHD_Connection Struct Reference

#include </builddir/build/BUILD/libmicrohttpd-0.9.72/src/lib/internal.h>

Data Fields

struct MHD_Connectionnext
 
struct MHD_Connectionprev
 
struct MHD_ConnectionnextX
 
struct MHD_ConnectionprevX
 
struct MHD_Daemondaemon
 
struct MemoryPool * pool
 
void * socket_context
 
ReceiveCallback recv_cls
 
TransmitCallback send_cls
 
struct MHD_Request request
 
MHD_thread_handle_ID_ pid
 
struct sockaddr_storage addr
 
socklen_t addr_len
 
time_t last_activity
 
time_t connection_timeout
 
MHD_socket socket_fd
 
bool suspended
 
bool tls_read_ready
 
bool resuming
 
bool thread_joined
 
bool sk_nonblck
 
bool read_closed
 
struct MHD_HTTP_Headerheaders_received
 
struct MHD_HTTP_Headerheaders_received_tail
 
struct MHD_Responseresponse
 
void * client_context
 
char * method
 
const char * url
 
char * version
 
enum MHD_ConnKeepAlive keepalive
 
char * read_buffer
 
char * write_buffer
 
char * last
 
char * colon
 
struct sockaddr * addr
 
size_t read_buffer_size
 
size_t read_buffer_offset
 
size_t write_buffer_size
 
size_t write_buffer_send_offset
 
size_t write_buffer_append_offset
 
size_t header_size
 
uint64_t remaining_upload_size
 
uint64_t response_write_position
 
size_t continue_message_write_offset
 
unsigned int connection_timeout_dummy
 
bool client_aware
 
bool sk_spipe_suppress
 
enum MHD_tristate sk_corked
 
enum MHD_tristate sk_nodelay
 
bool in_idle
 
bool in_cleanup
 
enum MHD_CONNECTION_STATE state
 
enum MHD_ConnectionEventLoopInfo event_loop_info
 
unsigned int responseCode
 
bool have_chunked_upload
 
uint64_t current_chunk_size
 
uint64_t current_chunk_offset
 
int suspended_dummy
 
volatile bool resuming
 

Detailed Description

State kept per HTTP connection.

State kept for each HTTP request.

Definition at line 633 of file internal.h.

Field Documentation

◆ addr [1/2]

struct sockaddr_storage MHD_Connection::addr

◆ addr [2/2]

struct sockaddr* MHD_Connection::addr

Foreign address (of length addr_len). MALLOCED (not in pool!).

Definition at line 817 of file internal.h.

◆ addr_len

socklen_t MHD_Connection::addr_len

Length of the foreign address.

Definition at line 733 of file internal.h.

Referenced by internal_add_connection(), internal_run_from_select(), and MHD_connection_cleanup_().

◆ client_aware

bool MHD_Connection::client_aware

Did we ever call the "default_handler" on this connection? (this flag will determine if we call the MHD_OPTION_NOTIFY_COMPLETED handler when the connection closes down).

Definition at line 917 of file internal.h.

Referenced by call_connection_handler(), check_write_done(), and MHD_connection_close_().

◆ client_context

void* MHD_Connection::client_context

We allow the main application to associate some pointer with the HTTP request, which is passed to each MHD_AccessHandlerCallback and some other API calls. Here is where we store it. (MHD does not know or care what it is).

Definition at line 748 of file internal.h.

Referenced by call_connection_handler(), check_write_done(), and MHD_connection_close_().

◆ colon

char* MHD_Connection::colon

Position after the colon on the last incomplete header line during parsing of headers. Allocated in pool. Only valid if state is either MHD_CONNECTION_HEADER_PART_RECEIVED or MHD_CONNECTION_FOOTER_PART_RECEIVED.

Definition at line 811 of file internal.h.

Referenced by process_header_line().

◆ connection_timeout

◆ connection_timeout_dummy

unsigned int MHD_Connection::connection_timeout_dummy

Special member to be returned by MHD_get_connection_info()

Definition at line 910 of file internal.h.

Referenced by MHD_get_connection_info().

◆ continue_message_write_offset

size_t MHD_Connection::continue_message_write_offset

Position in the 100 CONTINUE message that we need to send when receiving http 1.1 requests.

Definition at line 888 of file internal.h.

Referenced by MHD_connection_handle_write().

◆ current_chunk_offset

uint64_t MHD_Connection::current_chunk_offset

If we are receiving with chunked encoding, where are we currently with respect to the current chunk (at what offset / position)?

Definition at line 1017 of file internal.h.

Referenced by check_write_done().

◆ current_chunk_size

uint64_t MHD_Connection::current_chunk_size

If we are receiving with chunked encoding, where are we right now? Set to 0 if we are waiting to receive the chunk size; otherwise, this is the size of the current chunk. A value of zero is also used when we're at the end of the chunks.

Definition at line 1011 of file internal.h.

Referenced by check_write_done().

◆ daemon

◆ event_loop_info

enum MHD_ConnectionEventLoopInfo MHD_Connection::event_loop_info

What is this connection waiting for?

Definition at line 971 of file internal.h.

Referenced by MHD_connection_mark_closed_(), and MHD_connection_update_event_loop_info().

◆ have_chunked_upload

bool MHD_Connection::have_chunked_upload

Are we receiving with chunked encoding? This will be set to MHD_YES after we parse the headers and are processing the body with chunks. After we are done with the body and we are processing the footers; once the footers are also done, this will be set to MHD_NO again (before the final call to the handler).

Definition at line 1003 of file internal.h.

Referenced by check_write_done(), MHD_connection_handle_write(), and parse_connection_headers().

◆ header_size

size_t MHD_Connection::header_size

Number of bytes we had in the HTTP header, set once we pass MHD_CONNECTION_HEADERS_RECEIVED.

Definition at line 861 of file internal.h.

Referenced by MHD_get_connection_info().

◆ headers_received

struct MHD_HTTP_Header* MHD_Connection::headers_received

Linked list of parsed headers.

Definition at line 720 of file internal.h.

Referenced by MHD_get_connection_values(), MHD_get_connection_values_n(), MHD_lookup_connection_value_n(), and MHD_lookup_header_token_ci().

◆ headers_received_tail

struct MHD_HTTP_Header* MHD_Connection::headers_received_tail

Tail of linked list of parsed headers.

Definition at line 725 of file internal.h.

◆ in_cleanup

bool MHD_Connection::in_cleanup

Are we currently inside the "idle" handler (to avoid recursively invoking it).

Definition at line 971 of file internal.h.

Referenced by cleanup_connection().

◆ in_idle

bool MHD_Connection::in_idle

Are we currently inside the "idle" handler (to avoid recursively invoking it).

Definition at line 965 of file internal.h.

Referenced by cleanup_connection().

◆ keepalive

enum MHD_ConnKeepAlive MHD_Connection::keepalive

Close connection after sending response? Functions may change value from "Unknown" or "KeepAlive" to "Must close", but no functions reset value "Must Close" to any other value.

Definition at line 774 of file internal.h.

Referenced by transmit_error_response().

◆ last

char* MHD_Connection::last

Last incomplete header line during parsing of headers. Allocated in pool. Only valid if state is either MHD_CONNECTION_HEADER_PART_RECEIVED or MHD_CONNECTION_FOOTER_PART_RECEIVED.

Definition at line 802 of file internal.h.

Referenced by process_broken_line().

◆ last_activity

time_t MHD_Connection::last_activity

◆ method

char* MHD_Connection::method

Request method. Should be GET/POST/etc. Allocated in pool.

Definition at line 762 of file internal.h.

Referenced by call_connection_handler(), check_write_done(), and digest_auth_check_all().

◆ next

struct MHD_Connection * MHD_Connection::next

Next pointer for the DLL describing our IO state.

Definition at line 651 of file internal.h.

◆ nextX

struct MHD_Connection * MHD_Connection::nextX

Next pointer for the XDLL organizing connections by timeout. This DLL can be either the 'manual_timeout_head/manual_timeout_tail' or the 'normal_timeout_head/normal_timeout_tail', depending on whether a custom timeout is set for the connection.

Definition at line 665 of file internal.h.

◆ pid

MHD_thread_handle_ID_ MHD_Connection::pid

Thread handle for this connection (if we are using one thread per connection).

Definition at line 723 of file internal.h.

Referenced by cleanup_connection(), close_all_connections(), internal_run_from_select(), MHD_connection_cleanup_(), MHD_connection_close_(), MHD_daemon_close_all_connections_(), and thread_main_handle_connection().

◆ pool

struct MemoryPool * MHD_Connection::pool

The memory pool is created whenever we first read from the TCP stream and destroyed at the end of each request (and re-created for the next request). In the meantime, this pointer is NULL. The pool is used for all request-related data except for the response (which maybe shared between requests) and the IP address (which persists across individual requests).

The memory pool is created whenever we first read from the TCP stream and destroyed at the end of each request (and re-created for the next request). In the meantime, this pointer is NULL. The pool is used for all connection-related data except for the response (which maybe shared between connections) and the IP address (which persists across individual requests).

Definition at line 685 of file internal.h.

Referenced by build_header_response(), check_write_done(), internal_run_from_select(), MHD_connection_cleanup_(), MHD_connection_handle_read(), MHD_request_handle_idle_(), MHD_request_handle_read_(), parse_cookie_header(), process_broken_line(), transmit_error_response(), try_grow_read_buffer(), and try_ready_chunked_body().

◆ prev

struct MHD_Connection * MHD_Connection::prev

Previous pointer for the DLL describing our IO state.

Definition at line 656 of file internal.h.

Referenced by close_all_connections(), MHD_daemon_close_all_connections_(), and MHD_resume_suspended_connections_().

◆ prevX

struct MHD_Connection * MHD_Connection::prevX

Previous pointer for the XDLL organizing connections by timeout.

Definition at line 670 of file internal.h.

Referenced by MHD_daemon_get_timeout().

◆ read_buffer

char* MHD_Connection::read_buffer

Buffer for reading requests. Allocated in pool. Actually one byte larger than read_buffer_size (if non-NULL) to allow for 0-termination.

Definition at line 788 of file internal.h.

Referenced by build_header_response(), check_write_done(), connection_add_header(), MHD_connection_handle_read(), and transmit_error_response().

◆ read_buffer_offset

size_t MHD_Connection::read_buffer_offset

Position where we currently append data in read_buffer (last valid position).

Definition at line 839 of file internal.h.

Referenced by check_write_done(), connection_add_header(), get_next_header_line(), MHD_connection_handle_read(), and MHD_connection_update_event_loop_info().

◆ read_buffer_size

size_t MHD_Connection::read_buffer_size

Size of read_buffer (in bytes). This value indicates how many bytes we're willing to read into the buffer; the real buffer is one byte longer to allow for adding zero-termination (when needed).

Definition at line 833 of file internal.h.

Referenced by build_header_response(), connection_add_header(), MHD_connection_handle_read(), MHD_connection_update_event_loop_info(), and transmit_error_response().

◆ read_closed

bool MHD_Connection::read_closed

Has this socket been closed for reading (i.e. other side closed the connection)? If so, we must completely close the connection once we are done sending our response (and stop trying to read from this socket).

Definition at line 792 of file internal.h.

Referenced by build_header_response(), connection_update_event_loop_info(), method_string_to_enum(), MHD_connection_handle_read(), MHD_connection_update_event_loop_info(), MHD_request_handle_idle_(), MHD_request_handle_read_(), parse_connection_headers(), parse_request_headers(), response_action(), and transmit_error_response().

◆ recv_cls

ReceiveCallback MHD_Connection::recv_cls

Function used for reading HTTP request stream.

Definition at line 706 of file internal.h.

Referenced by MHD_connection_handle_read(), MHD_request_handle_read_(), MHD_set_http_callbacks_(), and MHD_set_https_callbacks().

◆ remaining_upload_size

uint64_t MHD_Connection::remaining_upload_size

How many more bytes of the body do we expect to read? MHD_SIZE_UNKNOWN for unknown.

Definition at line 867 of file internal.h.

Referenced by check_write_done(), and parse_connection_headers().

◆ request

◆ response

◆ response_write_position

uint64_t MHD_Connection::response_write_position

Current write position in the actual response (excluding headers, content only; should be 0 while sending headers).

Definition at line 874 of file internal.h.

Referenced by MHD_connection_handle_write().

◆ responseCode

unsigned int MHD_Connection::responseCode

HTTP response code. Only valid if response object is already set.

Definition at line 994 of file internal.h.

◆ resuming [1/2]

◆ resuming [2/2]

volatile bool MHD_Connection::resuming

Is the connection wanting to resume?

Definition at line 1076 of file internal.h.

◆ send_cls

TransmitCallback MHD_Connection::send_cls

Function used for writing HTTP response stream.

Definition at line 711 of file internal.h.

Referenced by MHD_request_handle_write_().

◆ sk_corked

enum MHD_tristate MHD_Connection::sk_corked

Tracks TCP_CORK / TCP_NOPUSH of the connection socket.

Definition at line 934 of file internal.h.

Referenced by internal_add_connection(), post_send_setopt(), pre_send_setopt(), and zero_send_().

◆ sk_nodelay

enum MHD_tristate MHD_Connection::sk_nodelay

Tracks TCP_NODELAY state of the connection socket.

Definition at line 934 of file internal.h.

Referenced by connection_set_nodelay_state_(), internal_add_connection(), post_send_setopt(), pre_send_setopt(), and zero_send_().

◆ sk_nonblck

bool MHD_Connection::sk_nonblck

true if socket_fd is non-blocking, false otherwise.

Definition at line 784 of file internal.h.

Referenced by internal_add_connection(), MHD_connection_call_handlers_(), and MHD_send_hdr_and_body_().

◆ sk_spipe_suppress

bool MHD_Connection::sk_spipe_suppress

true if connection socket has set SIGPIPE suppression

Definition at line 934 of file internal.h.

Referenced by internal_add_connection(), and MHD_send_hdr_and_body_().

◆ socket_context

void * MHD_Connection::socket_context

We allow the main application to associate some pointer with the TCP connection (which may span multiple HTTP requests). Here is where we store it. (MHD does not know or care what it is). The location is given to the MHD_NotifyConnectionCallback and also accessible via MHD_CONNECTION_INFO_SOCKET_CONTEXT.

Definition at line 694 of file internal.h.

Referenced by internal_run_from_select(), MHD_connection_get_information_sz(), and MHD_get_connection_info().

◆ socket_fd

◆ state

◆ suspended

◆ suspended_dummy

int MHD_Connection::suspended_dummy

Special member to be returned by MHD_get_connection_info()

Definition at line 1071 of file internal.h.

Referenced by MHD_get_connection_info().

◆ thread_joined

bool MHD_Connection::thread_joined

Set to true if the thread has been joined.

Definition at line 779 of file internal.h.

Referenced by close_all_connections(), internal_run_from_select(), MHD_connection_cleanup_(), and MHD_daemon_close_all_connections_().

◆ tls_read_ready

bool MHD_Connection::tls_read_ready

Are we ready to read from TLS for this connection?

Definition at line 769 of file internal.h.

Referenced by MHD_connection_call_handlers_(), recv_tls_adapter(), and thread_main_handle_connection().

◆ url

const char* MHD_Connection::url

Requested URL (everything after "GET" only). Allocated in pool.

Definition at line 768 of file internal.h.

Referenced by call_connection_handler(), check_write_done(), connection_add_header(), digest_auth_check_all(), MHD_connection_handle_write(), and MHD_connection_update_event_loop_info().

◆ version

char* MHD_Connection::version

HTTP version string (i.e. http/1.1). Allocated in pool.

Definition at line 774 of file internal.h.

Referenced by call_connection_handler(), check_write_done(), need_100_continue(), parse_connection_headers(), and transmit_error_response().

◆ write_buffer

char* MHD_Connection::write_buffer

Buffer for writing response (headers only). Allocated in pool.

Definition at line 794 of file internal.h.

Referenced by MHD_connection_handle_write().

◆ write_buffer_append_offset

size_t MHD_Connection::write_buffer_append_offset

Last valid location in write_buffer (where do we append and up to where is it safe to send?)

Definition at line 855 of file internal.h.

Referenced by MHD_connection_handle_write().

◆ write_buffer_send_offset

size_t MHD_Connection::write_buffer_send_offset

Offset where we are with sending from write_buffer.

Definition at line 849 of file internal.h.

Referenced by MHD_connection_handle_write().

◆ write_buffer_size

size_t MHD_Connection::write_buffer_size

Size of write_buffer (in bytes).

Definition at line 844 of file internal.h.


The documentation for this struct was generated from the following file: