3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#ifndef HTTP_SERVER_PRIVATE_H
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#define HTTP_SERVER_PRIVATE_H
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "connection.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch#include "iostream-pump.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#include "http-server.h"
833bed942977673526c72e79bccc09314fc57104Phil Carmody#include "llist.h"
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschstruct http_server_payload_handler;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server_request;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server_connection;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch/*
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch * Defaults
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch */
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch#define HTTP_SERVER_REQUEST_MAX_TARGET_LENGTH 4096
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch/*
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch * Types
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch */
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschenum http_server_request_state {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* New request; request header is still being parsed. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_NEW = 0,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Queued request; callback to request handler executing. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_QUEUED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Reading request payload; request handler still needs to read more
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch payload. */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_PAYLOAD_IN,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* This request is being processed; request payload is fully read, but no
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch response is yet submitted */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_PROCESSING,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* A response is submitted for this request. If not all request payload
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch was read by the handler, it is first skipped on the input.
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_SUBMITTED_RESPONSE,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Request is ready for response; a response is submitted and the request
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch payload is fully read */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_READY_TO_RESPOND,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* The response for the request is sent (apart from payload) */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_SENT_RESPONSE,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Sending response payload to client */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_PAYLOAD_OUT,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Request is finished; still lingering due to references */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_FINISHED,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch /* Request is aborted; still lingering due to references */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch HTTP_SERVER_REQUEST_STATE_ABORTED
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch/*
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch * Objects
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch */
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschstruct http_server_payload_handler {
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_request *req;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch void (*switch_ioloop)(struct http_server_payload_handler *handler);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch void (*destroy)(struct http_server_payload_handler *handler);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch bool in_callback:1;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch};
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server_response {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_request *request;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int status;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const char *reason;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch string_t *headers;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch time_t date;
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch ARRAY_TYPE(http_auth_challenge) auth_challenges;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct istream *payload_input;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch uoff_t payload_size, payload_offset;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ostream *payload_output;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
7c7117e542b6a44c1db7fc91c0180bdace6dbce7Stephan Bosch struct ostream *blocking_output;
7c7117e542b6a44c1db7fc91c0180bdace6dbce7Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch http_server_tunnel_callback_t tunnel_callback;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void *tunnel_context;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool have_hdr_connection:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool have_hdr_date:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool have_hdr_body_spec:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool payload_chunked:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool payload_blocking:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool payload_direct:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool payload_corked:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool submitted:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server_request {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_request req;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch pool_t pool;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int refcount;
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch unsigned int id;
dc05b1fb4b7a2b4d91248078311458cb4cbad9a1Stephan Bosch int callback_refcount;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch enum http_server_request_state state;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_request *prev, *next;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server *server;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_connection *conn;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch struct istream *payload_input;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_response *response;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*destroy_callback)(void *);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void *destroy_context;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool payload_halted:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool sent_100_continue:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool delay_destroy:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool destroy_pending:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool failed:1;
a5886aec87fbfd767a110e6168ce96411acfe798Stephan Bosch bool connection_close:1;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server_connection {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct connection conn;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server *server;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int refcount;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch const struct http_server_callbacks *callbacks;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void *context;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int id; // DEBUG
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct timeout *to_input, *to_idle;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ssl_iostream *ssl_iostream;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_request_parser *http_parser;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_request *request_queue_head, *request_queue_tail;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch unsigned int request_queue_count;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct istream *incoming_payload;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler *payload_handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct io *io_resp_payload;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch char *disconnect_reason;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_stats stats;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool ssl:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool closed:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool close_indicated:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool input_broken:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool output_locked:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool in_req_callback:1; /* performing request callback (busy) */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool switching_ioloop:1; /* in the middle of switching ioloop */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch pool_t pool;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_settings set;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ioloop *ioloop;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct ssl_iostream_context *ssl_ctx;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct connection_list *conn_list;
e1a4ea6ad3e799ef8df7395e765c0ae9218e6c5dStephan Bosch
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool shutting_down:1; /* shutting down server */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch};
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch/*
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch * Response
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch */
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschvoid http_server_response_free(struct http_server_response *resp);
3cda61e4ccaa1192528776d315f7ed5534315cb0Stephan Boschint http_server_response_send(struct http_server_response *resp);
3cda61e4ccaa1192528776d315f7ed5534315cb0Stephan Boschint http_server_response_send_more(struct http_server_response *resp);
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch/*
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch * Request
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch */
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstatic inline const char *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschhttp_server_request_label(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch if (req->req.method == NULL) {
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch if (req->req.target_raw == NULL)
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return t_strdup_printf("[Req%u: <NEW>]", req->id);
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return t_strdup_printf("[Req%u: %s <INCOMPLETE>]",
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch req->id, req->req.method);
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch }
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch return t_strdup_printf("[Req%u: %s %s]", req->id,
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch req->req.method, req->req.target_raw);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschstatic inline bool
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschhttp_server_request_is_new(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch return (req->state == HTTP_SERVER_REQUEST_STATE_NEW);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschstatic inline bool
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschhttp_server_request_version_equals(struct http_server_request *req,
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch unsigned int major, unsigned int minor) {
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch return (req->req.version_major == major && req->req.version_minor == minor);
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct http_server_request *
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschhttp_server_request_new(struct http_server_connection *conn);
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainenvoid http_server_request_destroy(struct http_server_request **_req);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Boschvoid http_server_request_abort(struct http_server_request **_req,
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch const char *reason) ATTR_NULL(2);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
9ec9b6f85c8fbe67bfac523a5e3d33d34f72dddcStephan Boschbool http_server_request_is_complete(struct http_server_request *req);
9ec9b6f85c8fbe67bfac523a5e3d33d34f72dddcStephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_halt_payload(struct http_server_request *req);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_continue_payload(struct http_server_request *req);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_submit_response(struct http_server_request *req);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_ready_to_respond(struct http_server_request *req);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_finished(struct http_server_request *req);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch/* payload handler */
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschvoid http_server_payload_handler_destroy(
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler **_handler);
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschvoid http_server_payload_handler_switch_ioloop(
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler *handler);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch/*
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch * connection
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch */
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschstatic inline const char *
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschhttp_server_connection_label(struct http_server_connection *conn)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch return conn->conn.name;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschstatic inline void
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschhttp_server_connection_add_request(struct http_server_connection *conn,
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch struct http_server_request *sreq)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch{
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch DLLIST2_APPEND(&conn->request_queue_head, &conn->request_queue_tail, sreq);
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch conn->request_queue_count++;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschstatic inline void
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschhttp_server_connection_remove_request(struct http_server_connection *conn,
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch struct http_server_request *sreq)
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch{
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch DLLIST2_REMOVE(&conn->request_queue_head, &conn->request_queue_tail, sreq);
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch conn->request_queue_count--;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch}
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschstruct connection_list *http_server_connection_list_init(void);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch
e1a4ea6ad3e799ef8df7395e765c0ae9218e6c5dStephan Boschbool http_server_connection_shut_down(struct http_server_connection *conn);
e1a4ea6ad3e799ef8df7395e765c0ae9218e6c5dStephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_connection_switch_ioloop(struct http_server_connection *conn);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch
e4b70fb422bf53ddf017948de26b5ea5a1a262fbStephan Boschvoid http_server_connection_handle_output_error(
e4b70fb422bf53ddf017948de26b5ea5a1a262fbStephan Bosch struct http_server_connection *conn);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Boschvoid http_server_connection_trigger_responses(
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch struct http_server_connection *conn);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Boschint http_server_connection_flush(struct http_server_connection *conn);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschint http_server_connection_output(struct http_server_connection *conn);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_connection_tunnel(struct http_server_connection **_conn,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch http_server_tunnel_callback_t callback, void *context);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Boschint http_server_connection_discard_payload(
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch struct http_server_connection *conn);
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Boschbool http_server_connection_pending_payload(
5560e4cd4f5eded857471042fb5485dfa16b7c46Stephan Bosch struct http_server_connection *conn);
833bed942977673526c72e79bccc09314fc57104Phil Carmody
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch#endif