http-server.h revision a5886aec87fbfd767a110e6168ce96411acfe798
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen * Server settings
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen /* The maximum time in milliseconds a client is allowed to be idle before
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen it is disconnected. */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen /* Maximum number of pipelined requests per connection (default = 1) */
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen /* Request limits */
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen /* The kernel send/receive buffer sizes used for the connection sockets.
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen Configuring this is mainly useful for the test suite. The kernel
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen defaults are used when these settings are 0. */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen /* Enable logging debug messages */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen/* Connection data for an established HTTP tunnel */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainentypedef void (*http_server_tunnel_callback_t)(void *context,
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen/* Start creating the response for the request. This function can be called
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen only once for each request. */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainenhttp_server_response_create(struct http_server_request *req,
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen/* Add a custom header to the response. This can override headers that are
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen otherwise created implicitly. */
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainenvoid http_server_response_add_header(struct http_server_response *resp,
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen/* Change the response code and text, cannot be used after submission */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainenvoid http_server_response_update_status(struct http_server_response *resp,
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen/* Set the value of the "Date" header for the response using a time_t value.
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen Use this instead of setting it directly using
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen http_server_response_add_header() */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainenvoid http_server_response_set_date(struct http_server_response *resp,
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen/* Assign an input stream for the outgoing payload of this response. The input
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen stream is read asynchronously while the response is sent to the client. */
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainenvoid http_server_response_set_payload(struct http_server_response *resp,
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen/* Assign payload data to the response. The data is copied to the request pool.
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen If your data is already durably allocated during the existence of the
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen response, you should consider using http_server_response_set_payload() with
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen a data input stream instead. This will avoid copying the data unnecessarily.
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainenvoid http_server_response_set_payload_data(struct http_server_response *resp,
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen/* Obtain an output stream for the response payload. This is an alternative to
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen using http_server_response_set_payload(). Currently, this can only return a
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen blocking output stream. The request is submitted implicitly once the output
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen stream is written to. Closing the stream concludes the payload. Destroying
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainen the stream before that aborts the response and closes the connection.
c8555d0f669c5732c8b9f5bece7b41fc65545f33Timo Sirainenhttp_server_response_get_payload_output(struct http_server_response *resp,
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainen/* Get the status code and reason string currently set for this response. */
596f582a422eddef951ee445f9a0ed3d4bf14ff8Timo Sirainenvoid http_server_response_get_status(struct http_server_response *resp,
const struct http_request *
bool close);
struct http_server_response *
struct istream *
bool blocking);
void (*callback)(void *),
void *context);
struct http_server_stats {
struct http_server_callbacks {
struct http_server_connection *
const char *reason);
const struct http_server_stats *