connection.c File Reference

Methods for managing connections. More...

#include "internal.h"
#include "connection.h"
#include "memorypool.h"
#include "response.h"
#include "reason_phrase.h"

Include dependency graph for connection.c:

Go to the source code of this file.

Defines

#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

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)
int MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
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)
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 do_fd_set (int fd, fd_set *set, int *max_fd)
int MHD_connection_get_fdset (struct MHD_Connection *connection, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *max_fd)
int MHD_connection_get_pollfd (struct MHD_Connection *connection, struct MHD_Pollfd *p)
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)
int MHD_connection_handle_read (struct MHD_Connection *connection)
int MHD_connection_handle_write (struct MHD_Connection *connection)
int MHD_connection_handle_idle (struct MHD_Connection *connection)
void MHD_set_http_callbacks_ (struct MHD_Connection *connection)
MHD_ConnectionInfoMHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType infoType,...)


Detailed Description

Methods for managing connections.

Author:
Daniel Pittman

Christian Grothoff

Definition in file connection.c.


Define Documentation

#define DEBUG_CLOSE   MHD_NO

Add extra debug messages with reasons for closing connections (non-error reasons).

Definition at line 99 of file connection.c.

#define DEBUG_SEND_DATA   MHD_NO

Should all data send be printed to stderr?

Definition at line 104 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 42 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 92 of file connection.c.

Referenced by MHD_connection_get_pollfd().

#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 67 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 80 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 54 of file connection.c.

Referenced by connection_add_header(), get_next_header_line(), MHD_connection_get_pollfd(), parse_cookie_header(), and process_broken_line().


Function Documentation

static void add_extra_headers ( struct MHD_Connection connection  )  [static]

Check if we need to set some additional headers for http-compiliance.

Definition at line 496 of file connection.c.

References MHD_Connection::have_chunked_upload, MHD_add_response_header(), MHD_get_response_header(), MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_HTTP_HEADER_TRANSFER_ENCODING, MHD_HTTP_VERSION_1_1, MHD_LONG_LONG, MHD_LONG_LONG_PRINTF, MHD_NO, MHD_SIZE_UNKNOWN, MHD_YES, NULL, MHD_Connection::response, SPRINTF, MHD_Response::total_size, and MHD_Connection::version.

Referenced by build_header_response().

Here is the call graph for this function:

Here is the caller graph for this function:

static int build_header_response ( struct MHD_Connection connection  )  [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.

Definition at line 596 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_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_YES, MHD_HTTP_Header::next, NULL, MHD_Connection::pool, MHD_Connection::response, SPRINTF, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 1215 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().

Here is the call graph for this function:

Here is the caller graph for this function:

static int 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".

Returns:
MHY_NO if we are not done, MHD_YES if we are

Definition at line 1519 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().

Here is the call graph for this function:

Here is the caller graph for this function:

static int connection_add_header ( struct MHD_Connection connection,
char *  key,
char *  value,
enum MHD_ValueKind  kind 
) [static]

Returns:
MHD_NO on failure (out of memory), MHD_YES for success

Definition at line 1003 of file connection.c.

References MHD_Connection::daemon, MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_NO, MHD_pool_allocate(), MHD_YES, MHD_HTTP_Header::next, NULL, MHD_Connection::pool, REQUEST_TOO_BIG, transmit_error_response(), and MHD_HTTP_Header::value.

Referenced by parse_arguments(), parse_cookie_header(), and process_broken_line().

Here is the call graph for this function:

Here is the caller graph for this function:

static void connection_close_error ( struct MHD_Connection connection  )  [static]

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

Definition at line 308 of file connection.c.

References MHD_connection_close(), and MHD_REQUEST_TERMINATED_WITH_ERROR.

Referenced by call_connection_handler(), do_read(), do_write(), MHD_connection_get_pollfd(), MHD_connection_handle_idle(), MHD_connection_handle_read(), MHD_connection_handle_write(), process_request_body(), try_ready_chunked_body(), and try_ready_normal_body().

Here is the call graph for this function:

Here is the caller graph for this function:

static void do_fd_set ( int  fd,
fd_set *  set,
int *  max_fd 
) [static]

Add "fd" to the "fd_set". If "fd" is greater than "*max", set "*max" to fd.

Definition at line 746 of file connection.c.

References NULL.

Referenced by MHD_connection_get_fdset().

Here is the caller graph for this function:

static int do_read ( struct MHD_Connection connection  )  [static]

Try reading data from the socket into the read buffer of the connection.

Returns:
MHD_YES if something changed, MHD_NO if we were interrupted or if no space was available

Definition at line 1426 of file connection.c.

References connection_close_error(), MHD_Connection::daemon, MHD_NO, MHD_USE_SSL, MHD_YES, MHD_Daemon::options, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, MHD_Connection::recv_cls, SHUTDOWN, MHD_Connection::socket_fd, and STRERROR.

Referenced by MHD_connection_handle_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int do_write ( struct MHD_Connection connection  )  [static]

Try writing data to the socket from the write buffer of the connection.

Returns:
MHD_YES if something changed, MHD_NO if we were interrupted

Definition at line 1475 of file connection.c.

References connection_close_error(), MHD_Connection::daemon, FPRINTF, MHD_NO, MHD_USE_SSL, MHD_YES, MHD_Daemon::options, MHD_Connection::send_cls, STRERROR, MHD_Connection::write_buffer, MHD_Connection::write_buffer_append_offset, and MHD_Connection::write_buffer_send_offset.

Referenced by MHD_connection_handle_write().

Here is the call graph for this function:

Here is the caller graph for this function:

static void get_date_string ( char *  date  )  [static]

Produce HTTP "Date:" header.

Parameters:
date where to write the header, with at least 128 bytes available space.

Definition at line 544 of file connection.c.

References SPRINTF.

Referenced by build_header_response().

Here is the caller graph for this function:

static char* get_next_header_line ( struct MHD_Connection connection  )  [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.

Definition at line 950 of file connection.c.

References MHD_BUF_INC_SIZE, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_HTTP_REQUEST_URI_TOO_LONG, MHD_pool_reallocate(), NULL, MHD_Connection::pool, MHD_Connection::read_buffer, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, REQUEST_TOO_BIG, and transmit_error_response().

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 287 of file connection.c.

References MHD_Connection::client_aware, MHD_Connection::client_context, CLOSE, MHD_Connection::daemon, MHD_CONNECTION_CLOSED, MHD_NO, MHD_YES, MHD_Daemon::notify_completed, NULL, SHUTDOWN, MHD_Connection::socket_fd, and MHD_Connection::state.

Referenced by connection_close_error(), MHD_close_connections(), MHD_connection_handle_idle(), MHD_handle_connection(), and MHD_tls_connection_close().

Here is the caller graph for this function:

int MHD_connection_get_fdset ( struct MHD_Connection connection,
fd_set *  read_fd_set,
fd_set *  write_fd_set,
fd_set *  except_fd_set,
int *  max_fd 
)

Obtain the select sets for this connection

Returns:
MHD_YES on success

Definition at line 760 of file connection.c.

References do_fd_set(), MHD_Pollfd::events, MHD_Pollfd::fd, MHD_connection_get_pollfd(), MHD_POLL_ACTION_IN, MHD_POLL_ACTION_OUT, and MHD_YES.

Referenced by MHD_get_fdset(), and MHD_handle_connection().

Here is the call graph for this function:

Here is the caller graph for this function:

int MHD_connection_get_pollfd ( struct MHD_Connection connection,
struct MHD_Pollfd p 
)

Obtain the pollfd for this connection

Returns:
MHD_YES on success. If return MHD_YES and p->fd < 0, this connection is not waiting for any read or write events

Definition at line 786 of file connection.c.

References connection_close_error(), MHD_Connection::daemon, MHD_Pollfd::events, EXTRA_CHECK, MHD_Pollfd::fd, 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_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, MHD_HTTP_REQUEST_URI_TOO_LONG, MHD_NO, MHD_POLL_ACTION_IN, MHD_POLL_ACTION_OUT, MHD_pool_create(), MHD_TLS_CONNECTION_INIT, MHD_USE_SELECT_INTERNALLY, MHD_USE_THREAD_PER_CONNECTION, MHD_YES, NULL, MHD_Connection::pool, MHD_Daemon::pool_size, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::read_closed, REQUEST_TOO_BIG, MHD_Connection::socket_fd, MHD_Connection::state, transmit_error_response(), and try_grow_read_buffer().

Referenced by MHD_connection_get_fdset(), and MHD_handle_connection().

Here is the call graph for this function:

Here is the caller graph for this function:

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. All implementations (multithreaded, external select, internal select) call this function.

Returns:
MHD_YES if we should continue to process the connection (not dead yet), MHD_NO if it died

Definition at line 1938 of file connection.c.

References build_header_response(), call_connection_handler(), connection_close_error(), MHD_Daemon::connection_timeout, MHD_Connection::daemon, EXTRA_CHECK, get_next_header_line(), HTTP_100_CONTINUE, MHD_Connection::last_activity, 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_URL_RECEIVED, MHD_destroy_response(), MHD_FOOTER_KIND, MHD_HEADER_KIND, MHD_HTTP_BAD_REQUEST, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_VERSION_1_1, MHD_lookup_connection_value(), MHD_NO, MHD_pool_destroy(), MHD_pool_reset(), MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED, MHD_SIZE_UNKNOWN, MHD_YES, need_100_continue(), NULL, parse_connection_headers(), parse_initial_message_line(), process_broken_line(), process_header_line(), process_request_body(), MHD_Connection::read_closed, REQUEST_MALFORMED, MHD_Connection::socket_fd, MHD_Connection::state, transmit_error_response(), try_ready_chunked_body(), and try_ready_normal_body().

Referenced by MHD_set_http_callbacks_(), and MHD_tls_connection_handle_idle().

Here is the call graph for this function:

Here is the caller graph for this function:

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. All implementations (multithreaded, external select, internal select) call this function to handle reads.

Returns:
MHD_YES if we should continue to process the connection (not dead yet), MHD_NO if it died

Definition at line 1722 of file connection.c.

References connection_close_error(), do_read(), MHD_Connection::last_activity, MHD_BUF_INC_SIZE, MHD_CONNECTION_BODY_RECEIVED, 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_YES, NULL, MHD_Connection::read_buffer_offset, MHD_Connection::read_buffer_size, MHD_Connection::state, and try_grow_read_buffer().

Referenced by MHD_set_http_callbacks_(), and MHD_tls_connection_handle_read().

Here is the call graph for this function:

Here is the caller graph for this function:

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. All implementations (multithreaded, external select, internal select) call this function

Returns:
MHD_YES if we should continue to process the connection (not dead yet), MHD_NO if it died

Definition at line 1785 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, FPRINTF, HTTP_100_CONTINUE, MHD_Connection::last_activity, 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_NO, MHD_TLS_CONNECTION_INIT, MHD_YES, MHD_Response::mutex, NULL, MHD_Connection::response, MHD_Connection::send_cls, MHD_Connection::state, STRERROR, and try_ready_normal_body().

Referenced by MHD_set_http_callbacks_(), and MHD_tls_connection_handle_write().

Here is the call graph for this function:

Here is the caller graph for this function:

union MHD_ConnectionInfo* MHD_get_connection_info ( struct MHD_Connection connection,
enum MHD_ConnectionInfoType  infoType,
  ... 
)

Obtain information about the given connection.

Parameters:
connection what connection to get information about
infoType what information is desired?
... depends on infoType
Returns:
NULL if this information is not available (or if the infoType is unknown)

Definition at line 2303 of file connection.c.

References MHD_Connection::addr, MHD_CONNECTION_INFO_CIPHER_ALGO, MHD_CONNECTION_INFO_CLIENT_ADDRESS, MHD_CONNECTION_INFO_GNUTLS_SESSION, MHD_CONNECTION_INFO_PROTOCOL, and NULL.

int MHD_get_connection_values ( struct MHD_Connection connection,
enum MHD_ValueKind  kind,
MHD_KeyValueIterator  iterator,
void *  iterator_cls 
)

Get all of the headers from the request.

Parameters:
iterator callback to call on each header; maybe NULL (then just count headers)
iterator_cls extra argument to iterator
Returns:
number of entries iterated over

Definition at line 115 of file connection.c.

References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.

const char* MHD_lookup_connection_value ( struct MHD_Connection connection,
enum MHD_ValueKind  kind,
const char *  key 
)

Get a particular header value. If multiple values match the kind, return any one of them.

Parameters:
key the header to look for
Returns:
NULL if no such item was found

Definition at line 197 of file connection.c.

References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.

Referenced by MHD_basic_auth_get_username_password(), MHD_connection_handle_idle(), MHD_create_post_processor(), MHD_digest_auth_check(), MHD_digest_auth_get_username(), need_100_continue(), parse_connection_headers(), and parse_cookie_header().

Here is the caller graph for this function:

int MHD_queue_response ( struct MHD_Connection connection,
unsigned int  status_code,
struct MHD_Response response 
)

Queue a response to be transmitted to the client (as soon as possible but after MHD_AccessHandlerCallback returns).

Parameters:
connection the connection identifying the client
status_code HTTP status code (i.e. 200 for OK)
response response to transmit
Returns:
MHD_NO on error (i.e. reply already sent), MHD_YES on success or if message has been queued

Definition at line 225 of file connection.c.

References MHD_Connection::have_chunked_response, MHD_Connection::method, MHD_CONNECTION_FOOTERS_RECEIVED, MHD_CONNECTION_HEADERS_PROCESSED, MHD_HTTP_METHOD_HEAD, MHD_HTTP_VERSION_1_1, MHD_increment_response_rc(), MHD_NO, MHD_SIZE_UNKNOWN, MHD_YES, NULL, MHD_Connection::read_closed, MHD_Connection::response, MHD_Connection::response_write_position, MHD_Connection::responseCode, SHUTDOWN, MHD_Connection::socket_fd, MHD_Connection::state, MHD_Response::total_size, and MHD_Connection::version.

Referenced by MHD_queue_auth_fail_response(), MHD_queue_basic_auth_fail_response(), parse_connection_headers(), and transmit_error_response().

Here is the call graph for this function:

Here is the caller graph for this function:

int MHD_set_connection_value ( struct MHD_Connection connection,
enum MHD_ValueKind  kind,
const char *  key,
const char *  value 
)

This function can be used to add an entry to the HTTP headers of a connection (so that the MHD_get_connection_values function will return them -- and the MHD PostProcessor will also see them). This maybe required in certain situations (see Mantis #1399) where (broken) HTTP implementations fail to supply values needed by the post processor (or other parts of the application).

This function MUST only be called from within the MHD_AccessHandlerCallback (otherwise, access maybe improperly synchronized). Furthermore, the client must guarantee that the key and value arguments are 0-terminated strings that are NOT freed until the connection is closed. (The easiest way to do this is by passing only arguments to permanently allocated strings.).

Parameters:
connection the connection for which a value should be set
kind kind of the value
key key for the value
value the value itself
Returns:
MHD_NO if the operation could not be performed due to insufficient memory; MHD_YES on success

Definition at line 171 of file connection.c.

References MHD_HTTP_Header::header, MHD_Connection::headers_received, MHD_HTTP_Header::kind, MHD_NO, MHD_pool_allocate(), MHD_YES, MHD_HTTP_Header::next, NULL, MHD_Connection::pool, and MHD_HTTP_Header::value.

Here is the call graph for this function:

void MHD_set_http_callbacks_ ( struct MHD_Connection connection  ) 

Definition at line 2285 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 MHD_accept_connection().

Here is the call graph for this function:

Here is the caller graph for this function:

static int need_100_continue ( struct MHD_Connection connection  )  [static]

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

Definition at line 266 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().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_arguments ( enum MHD_ValueKind  kind,
struct MHD_Connection connection,
char *  args 
) [static]

Returns:
MHD_NO on failure (out of memory), MHD_YES for success

Definition at line 1032 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().

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_connection_headers ( struct MHD_Connection connection  )  [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.

Definition at line 1643 of file connection.c.

References MHD_Connection::daemon, EXTRA_CHECK, MHD_Connection::have_chunked_upload, MHD_CONNECTION_CLOSED, 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_LONG_LONG, MHD_LONG_LONG_PRINTF, MHD_lookup_connection_value(), MHD_queue_response(), MHD_RESPMEM_PERSISTENT, MHD_SIZE_UNKNOWN, 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, SSCANF, MHD_Connection::state, and MHD_Connection::version.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_cookie_header ( struct MHD_Connection connection  )  [static]

Parse the cookie header (see RFC 2109).

Returns:
MHD_YES for success, MHD_NO for failure (malformed, out of memory)

Definition at line 1070 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, old, MHD_Connection::pool, REQUEST_TOO_BIG, and transmit_error_response().

Referenced by parse_connection_headers().

Here is the call graph for this function:

Here is the caller graph for this function:

static int parse_initial_message_line ( struct MHD_Connection connection,
char *  line 
) [static]

Parse the first line of the HTTP HEADER.

Parameters:
connection the connection (updated)
line the first line
Returns:
MHD_YES if the line is ok, MHD_NO if it is malformed

Definition at line 1165 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_Connection::url, and MHD_Connection::version.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_broken_line ( struct MHD_Connection connection,
char *  line,
enum MHD_ValueKind  kind 
) [static]

Process a header value that spans multiple lines. The previous line(s) are in connection->last.

Parameters:
line the current input line
kind if the line is complete, add a header of the given kind
Returns:
MHD_YES if the line was processed successfully

Definition at line 1582 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().

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_header_line ( struct MHD_Connection connection,
char *  line 
) [static]

We have received (possibly the beginning of) a line in the header (or footer). Validate (check for ":") and prepare to process.

Definition at line 1541 of file connection.c.

References MHD_Connection::colon, MHD_Connection::daemon, MHD_Connection::last, MHD_CONNECTION_CLOSED, MHD_NO, MHD_YES, NULL, and MHD_Connection::state.

Referenced by MHD_connection_handle_idle(), and process_broken_line().

Here is the caller graph for this function:

static void process_request_body ( struct MHD_Connection connection  )  [static]

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

Definition at line 1250 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, SSCANF, MHD_Connection::url, and MHD_Connection::version.

Referenced by MHD_connection_handle_idle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void transmit_error_response ( struct MHD_Connection connection,
unsigned int  status_code,
const char *  message 
) [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:
status_code the response code to send (400, 413 or 414)

Definition at line 701 of file connection.c.

References build_header_response(), MHD_Connection::daemon, EXTRA_CHECK, MHD_CONNECTION_CLOSED, 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_get_pollfd(), MHD_connection_handle_idle(), parse_cookie_header(), and process_broken_line().

Here is the call graph for this function:

Here is the caller graph for this function:

static int try_grow_read_buffer ( struct MHD_Connection connection  )  [static]

Try growing the read buffer

Returns:
MHD_YES on success, MHD_NO on failure

Definition at line 571 of file connection.c.

References MHD_BUF_INC_SIZE, MHD_NO, MHD_pool_reallocate(), MHD_YES, NULL, MHD_Connection::pool, MHD_Connection::read_buffer, and MHD_Connection::read_buffer_size.

Referenced by MHD_connection_get_pollfd(), and MHD_connection_handle_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int try_ready_chunked_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).

Returns:
MHD_NO if readying the response failed

Definition at line 393 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
MHD_NO if readying the response failed

Definition at line 324 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_CONTENT_READER_END_OF_STREAM, MHD_CONTENT_READER_END_WITH_ERROR, MHD_MIN, MHD_NO, mhd_panic, mhd_panic_cls, MHD_USE_SELECT_INTERNALLY, MHD_USE_SSL, MHD_YES, NULL, MHD_Daemon::options, MHD_Connection::response, MHD_Connection::response_write_position, 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:


Generated on Thu May 10 14:38:02 2012 for GNU libmicrohttpd by  doxygen 1.4.7