http-server-private.h revision 3cda61e4ccaa1192528776d315f7ed5534315cb0
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define HTTP_SERVER_REQUEST_MAX_TARGET_LENGTH 4096
aef92409cf369afdd2ecd81a4f80083cd4082f46Timo Sirainen /* New request; request header is still being parsed. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Queued request; callback to request handler executing. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* Reading request payload; request handler still needs to read more
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen /* This request is being processed; request payload is fully read, but no
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen response is yet submitted */
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen /* A response is submitted for this request. If not all request payload
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen was read by the handler, it is first skipped on the input.
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen /* Request is ready for response; a response is submitted and the request
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainen payload is fully read */
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen /* The response for the request is sent (apart from payload) */
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen /* Sending response payload to client */
e188bab0b830136d04a1dd8b55e9afefae20d930Timo Sirainen /* Request is finished; still lingering due to references */
5a3f143585110536a7f72628e66a42b998bfc5fcTimo Sirainen /* Request is aborted; still lingering due to references */
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen void (*switch_ioloop)(struct http_server_payload_handler *handler);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen void (*destroy)(struct http_server_payload_handler *handler);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int status;
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen ARRAY_TYPE(http_auth_challenge) auth_challenges;
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen http_server_tunnel_callback_t tunnel_callback;
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen unsigned int id;
894987bf45718f8849cc3898afdfb1ac3cfa2445Timo Sirainen void (*destroy_callback)(void *);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen const struct http_server_callbacks *callbacks;
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen struct http_server_request *request_queue_head, *request_queue_tail;
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen struct http_server_payload_handler *payload_handler;
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen bool in_req_callback:1; /* performing request callback (busy) */
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainen bool switching_ioloop:1; /* in the middle of switching ioloop */
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen bool shutting_down:1; /* shutting down server */
0d70a702dec63d22535684fec6a7247c5f153208Timo Sirainenvoid http_server_response_free(struct http_server_response *resp);
0d70a702dec63d22535684fec6a7247c5f153208Timo Sirainenint http_server_response_send(struct http_server_response *resp);
0d70a702dec63d22535684fec6a7247c5f153208Timo Sirainenint http_server_response_send_more(struct http_server_response *resp);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenstatic inline const char *
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenhttp_server_request_label(struct http_server_request *req)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen return t_strdup_printf("[Req%u: <NEW>]", req->id);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen return t_strdup_printf("[Req%u: %s <INCOMPLETE>]",
2d49f150b4bce6f2f59a84e268e4777901c3e42cTimo Sirainen return t_strdup_printf("[Req%u: %s %s]", req->id,
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenstatic inline bool
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenhttp_server_request_is_new(struct http_server_request *req)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen return (req->state == HTTP_SERVER_REQUEST_STATE_NEW);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenstatic inline bool
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenhttp_server_request_version_equals(struct http_server_request *req,
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen return (req->req.version_major == major && req->req.version_minor == minor);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenhttp_server_request_new(struct http_server_connection *conn);
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainenvoid http_server_request_destroy(struct http_server_request **_req);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid http_server_request_abort(struct http_server_request **_req,
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenbool http_server_request_is_complete(struct http_server_request *req);
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenvoid http_server_request_halt_payload(struct http_server_request *req);
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenvoid http_server_request_continue_payload(struct http_server_request *req);
096953143c4032bad154637f687551856f7946cbTimo Sirainenvoid http_server_request_submit_response(struct http_server_request *req);
c680a6b35b459045e92814778908da5a93922107Timo Sirainenvoid http_server_request_ready_to_respond(struct http_server_request *req);
c680a6b35b459045e92814778908da5a93922107Timo Sirainenvoid http_server_request_finished(struct http_server_request *req);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* payload handler */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct http_server_payload_handler **_handler);
5f78b33aa505b17e23cdf27b071a24e127b3db54Timo Sirainenvoid http_server_payload_handler_switch_ioloop(
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic inline const char *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenhttp_server_connection_label(struct http_server_connection *conn)
95a1a5195d56f3cf5d1e529aad668f87ad3b979bTimo Sirainenstatic inline void
95a1a5195d56f3cf5d1e529aad668f87ad3b979bTimo Sirainenhttp_server_connection_add_request(struct http_server_connection *conn,
c9c24293550541307f1bb41bba4a0fdfe2fa59e0Timo Sirainen DLLIST2_APPEND(&conn->request_queue_head, &conn->request_queue_tail, sreq);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstatic inline void
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenhttp_server_connection_remove_request(struct http_server_connection *conn,
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen DLLIST2_REMOVE(&conn->request_queue_head, &conn->request_queue_tail, sreq);
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainenstruct connection_list *http_server_connection_list_init(void);
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainenbool http_server_connection_shut_down(struct http_server_connection *conn);
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainenvoid http_server_connection_switch_ioloop(struct http_server_connection *conn);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid http_server_connection_handle_output_error(
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint http_server_connection_flush(struct http_server_connection *conn);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint http_server_connection_output(struct http_server_connection *conn);
3ee5f5427b36ea30a01561b35f4002232db7b061Timo Sirainenvoid http_server_connection_tunnel(struct http_server_connection **_conn,