http-server-request.c revision 31300f53eadd34fc7bd567b2424565a60c06e2f5
2e37d45867d081db150ab78dad303b9077aea24fTimo Sirainen/* Copyright (c) 2013-2016 Dovecot authors, see the included COPYING file */
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenstatic inline void
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenhttp_server_request_debug(struct http_server_request *req,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenstatic inline void
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenhttp_server_request_debug(struct http_server_request *req,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen const char *format, ...)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenhttp_server_request_new(struct http_server_connection *conn)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen static unsigned int id_counter = 0;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen pool = pool_alloconly_create(MEMPOOL_GROWING"http_server_request", 4096);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen req = p_new(pool, struct http_server_request, 1);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen http_server_connection_add_request(conn, req);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenvoid http_server_request_ref(struct http_server_request *req)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenbool http_server_request_unref(struct http_server_request **_req)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen struct http_server_connection *conn = req->conn;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED) {
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen req->state = HTTP_SERVER_REQUEST_STATE_ABORTED;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen http_server_connection_remove_request(conn, req);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenvoid http_server_request_destroy(struct http_server_request **_req)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen /* just make sure the request ends in a proper state */
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen req->state = HTTP_SERVER_REQUEST_STATE_ABORTED;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen void (*callback)(void *) = req->destroy_callback;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenvoid http_server_request_set_destroy_callback(struct http_server_request *req,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen void (*callback)(void *),
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenvoid http_server_request_abort(struct http_server_request **_req,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen struct http_server_connection *conn = req->conn;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (req->state >= HTTP_SERVER_REQUEST_STATE_FINISHED)
static const char *response =
const struct http_request *
struct http_server_response *
const char *auth;
i_unreached();
static struct http_server_response *
return resp;
if (close)
struct http_server_istream {
static ssize_t
return ret;
struct istream *
bool blocking)