bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic inline void
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschhttp_server_request_debug(struct http_server_request *req,
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschstatic inline void
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Boschhttp_server_request_debug(struct http_server_request *req,
2f64a4c88de91c483fb378bc80d10e1caa6f2305Stephan Bosch const char *format, ...)
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschstatic inline void
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschhttp_server_request_error(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschstatic inline void
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschhttp_server_request_error(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch const char *format, ...)
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschstatic inline void
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschhttp_server_request_client_error(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschstatic inline void
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschhttp_server_request_client_error(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch const char *format, ...)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschhttp_server_request_new(struct http_server_connection *conn)
45324f1eafa565dbc65e4dd335de9507dead55e6Timo Sirainen pool = pool_alloconly_create(MEMPOOL_GROWING"http_server_request", 4096);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch req = p_new(pool, struct http_server_request, 1);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_ref(struct http_server_request *req)
1e9296de32c9ddda40f33c06556cd568ddadf71fTimo Sirainenbool http_server_request_unref(struct http_server_request **_req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_connection *conn = req->conn;
833bed942977673526c72e79bccc09314fc57104Phil Carmody if (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED) {
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch req->state = HTTP_SERVER_REQUEST_STATE_ABORTED;
833bed942977673526c72e79bccc09314fc57104Phil Carmody http_server_connection_remove_request(conn, req);
a5886aec87fbfd767a110e6168ce96411acfe798Stephan Boschvoid http_server_request_connection_close(struct http_server_request *req,
a5886aec87fbfd767a110e6168ce96411acfe798Stephan Bosch i_assert(req->state < HTTP_SERVER_REQUEST_STATE_SENT_RESPONSE);
faa8995f1d300e7a8917407a52bbd1b98e10bf25Timo Sirainenvoid http_server_request_destroy(struct http_server_request **_req)
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch /* just make sure the request ends in a proper state */
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch if (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED)
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch req->state = HTTP_SERVER_REQUEST_STATE_ABORTED;
9f8cef4cbc49797053c343209ea13022fdbc5a63Stephan Bosch void (*callback)(void *) = req->destroy_callback;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_set_destroy_callback(struct http_server_request *req,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch void (*callback)(void *),
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Boschvoid http_server_request_abort(struct http_server_request **_req,
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_connection *conn = req->conn;
31300f53eadd34fc7bd567b2424565a60c06e2f5Stephan Bosch if (req->state >= HTTP_SERVER_REQUEST_STATE_FINISHED)
833bed942977673526c72e79bccc09314fc57104Phil Carmody if (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED) {
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch http_server_connection_remove_request(conn, req);
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch /* send best-effort response if appropriate */
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch req->state >= HTTP_SERVER_REQUEST_STATE_PROCESSING &&
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch req->state < HTTP_SERVER_REQUEST_STATE_SENT_RESPONSE) {
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch "HTTP/1.1 500 Internal Server Error\r\n"
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch "Content-Length: 0\r\n"
ee2633056e67353157bfbce4d9e0d1c3ceaa627aStephan Bosch /* close the connection */
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch req->state = HTTP_SERVER_REQUEST_STATE_ABORTED;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschhttp_server_request_get(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschhttp_server_request_get_pool(struct http_server_request *req)
85f3bd5926fff0e70b6d259a5c8074bd8cdeb9adTimo Sirainenhttp_server_request_get_response(struct http_server_request *req)
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschint http_server_request_get_auth(struct http_server_request *req,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch auth = http_request_header_get(&req->req, "Authorization");
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch ((const unsigned char *)auth, strlen(auth), credentials) < 0)
93ed69606237a08623f8294c060fa148880058f8Timo Sirainenbool http_server_request_is_finished(struct http_server_request *req)
93ed69606237a08623f8294c060fa148880058f8Timo Sirainen req->state == HTTP_SERVER_REQUEST_STATE_ABORTED;
9ec9b6f85c8fbe67bfac523a5e3d33d34f72dddcStephan Boschbool http_server_request_is_complete(struct http_server_request *req)
9ec9b6f85c8fbe67bfac523a5e3d33d34f72dddcStephan Bosch return (req->failed || req->conn->input_broken ||
9ec9b6f85c8fbe67bfac523a5e3d33d34f72dddcStephan Bosch (req->next != NULL && !http_server_request_is_new(req->next)) ||
9ec9b6f85c8fbe67bfac523a5e3d33d34f72dddcStephan Bosch !http_server_connection_pending_payload(req->conn));
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_halt_payload(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch i_assert(req->state <= HTTP_SERVER_REQUEST_STATE_QUEUED);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_continue_payload(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch i_assert(req->state <= HTTP_SERVER_REQUEST_STATE_QUEUED);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch if (req->req.expect_100_continue && !req->sent_100_continue)
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch http_server_connection_trigger_responses(req->conn);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_ready_to_respond(struct http_server_request *req)
390b600a6f7fdb4ccc65950527ee30129f49a6acStephan Bosch http_server_request_debug(req, "Ready to respond");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch req->state = HTTP_SERVER_REQUEST_STATE_READY_TO_RESPOND;
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch http_server_connection_trigger_responses(req->conn);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_submit_response(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_connection *conn = req->conn;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch i_assert(conn != NULL && req->response != NULL && req->response->submitted);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch if (conn->payload_handler != NULL && conn->payload_handler->req == req)
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch http_server_payload_handler_destroy(&conn->payload_handler);
390b600a6f7fdb4ccc65950527ee30129f49a6acStephan Bosch http_server_request_debug(req, "Not ready to respond");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch req->state = HTTP_SERVER_REQUEST_STATE_SUBMITTED_RESPONSE;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch case HTTP_SERVER_REQUEST_STATE_READY_TO_RESPOND:
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch http_server_connection_trigger_responses(req->conn);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Boschvoid http_server_request_finished(struct http_server_request *req)
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_connection *conn = req->conn;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch struct http_server_response *resp = req->response;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch http_server_tunnel_callback_t tunnel_callback = resp->tunnel_callback;
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch i_assert(req->state < HTTP_SERVER_REQUEST_STATE_FINISHED);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch req->state = HTTP_SERVER_REQUEST_STATE_FINISHED;
833bed942977673526c72e79bccc09314fc57104Phil Carmody http_server_connection_remove_request(conn, req);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch t_strdup_printf("Server closed connection: %u %s",
e2a5de324df523512c42086d8422e4e41adf2c28Stephan Bosch "Connection input is broken");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch "Client requested connection close");
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch http_server_connection_tunnel(&conn, tunnel_callback, tunnel_context);
711e8e4c5c5d702dfa062f42a1ede5de14c151c9Stephan Bosch http_server_connection_trigger_responses(conn);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschhttp_server_request_create_fail_response(struct http_server_request *req,
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch unsigned int status, const char *reason, const char *text)
355a3cf3f2fad0293614cb3ed533629d52967f27Stephan Bosch i_assert(status / 100 != 1 && status != 204 && status != 304);
3fcb3d2d1f3583025ff62bae95ec706920f398b1Stephan Bosch resp = http_server_response_create(req, status, reason);
355a3cf3f2fad0293614cb3ed533629d52967f27Stephan Bosch if (!http_request_method_is(&req->req, "HEAD")) {
355a3cf3f2fad0293614cb3ed533629d52967f27Stephan Bosch (resp, "Content-Type", "text/plain; charset=utf-8");
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch (resp, (const unsigned char *)text, strlen(text));
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschhttp_server_request_fail_full(struct http_server_request *req,
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch unsigned int status, const char *reason, const char *text)
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch resp = http_server_request_create_fail_response(req,
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenvoid http_server_request_fail(struct http_server_request *req,
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch http_server_request_fail_full(req, status, reason, NULL);
95e0b82fdff1bb511067d703bb8b67c22f242c38Timo Sirainenvoid http_server_request_fail_close(struct http_server_request *req,
a5886aec87fbfd767a110e6168ce96411acfe798Stephan Bosch http_server_request_connection_close(req, TRUE);
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch http_server_request_fail_full(req, status, reason, NULL);
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Boschvoid http_server_request_fail_text(struct http_server_request *req,
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch unsigned int status, const char *reason, const char *format, ...)
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch http_server_request_fail_full(req, status, reason,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschvoid http_server_request_fail_auth(struct http_server_request *req,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch const char *reason, const struct http_auth_challenge *chlng)
001b7ca6a75e7052511420f9394ed7a7cf008f4aStephan Bosch resp = http_server_request_create_fail_response(req,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Boschvoid http_server_request_fail_auth_basic(struct http_server_request *req,
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch http_auth_basic_challenge_init(&chlng, realm);
564e117d86ce5b659f9b9570edddc566f9ebb5dfStephan Bosch http_server_request_fail_auth(req, reason, &chlng);
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch * Payload input stream
038c2831447440bf0bef89b43dd0968afc298abcStephan Boschhttp_server_istream_switch_ioloop_to(struct istream_private *stream,
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch http_server_connection_switch_ioloop(hsristream->req->conn);
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Boschhttp_server_istream_read_any(struct http_server_istream *hsristream)
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch struct istream_private *stream = &hsristream->istream;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch struct http_server *server = hsristream->req->server;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Boschhttp_server_istream_read(struct istream_private *stream)
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch struct http_server_request *req = hsristream->req;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch /* request already gone (we shouldn't get here) */
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch i_stream_seek(stream->parent, stream->parent_start_offset +
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch ret = i_stream_read_copy_from_parent(&stream->istream);
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch if (blocking && req->req.expect_100_continue &&
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch http_server_connection_trigger_responses(conn);
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch while (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED &&
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Boschhttp_server_istream_destroy(struct iostream_private *stream)
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch v_offset = hsristream->istream.parent_start_offset +
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch v_offset > hsristream->istream.parent->v_offset) {
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch /* get to same position in parent stream */
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch i_stream_seek(hsristream->istream.parent, v_offset);
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Boschhttp_server_request_get_payload_input(struct http_server_request *req,
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch hsristream = i_new(struct http_server_istream, 1);
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch hsristream->istream.stream_size_passthrough = TRUE;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch hsristream->istream.read = http_server_istream_read;
038c2831447440bf0bef89b43dd0968afc298abcStephan Bosch hsristream->istream.switch_ioloop_to = http_server_istream_switch_ioloop_to;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch hsristream->istream.iostream.destroy = http_server_istream_destroy;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch hsristream->istream.istream.readable_fd = FALSE;
201c3b9375760bafbc180629b4c6ad71ed554aecStephan Bosch hsristream->istream.istream.blocking = blocking;
2974dca6be5120e49279f06c8aa952e5fac56048Timo Sirainen (&hsristream->istream, payload, i_stream_get_fd(payload), 0);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch * Payload handling
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_connection *conn = req->conn;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler **_handler)
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler *handler = *_handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_connection *conn = handler->req->conn;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch /* don't destroy handler while in callback */
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschvoid http_server_payload_handler_switch_ioloop(
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch/* pump-based */
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_pump *phandler =
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch (struct http_server_payload_handler_pump *)handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_pump *phandler =
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch (struct http_server_payload_handler_pump *)handler;
39435f00a35a276d329283179b3e7e0351482939Timo Sirainenpayload_handler_pump_callback(enum iostream_pump_status status,
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_pump *phandler)
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler *handler = &phandler->handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_request *req = handler->req;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_connection *conn = req->conn;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct istream *input = iostream_pump_get_input(phandler->pump);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct ostream *output = iostream_pump_get_output(phandler->pump);
1bc075e2e4ed422f9590c95c3ae223422b97ce6aTimo Sirainen if (!i_stream_read_eof(conn->incoming_payload)) {
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch req->callback_refcount += req->refcount - old_refcount;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch (req->response != NULL && req->response->submitted));
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch "iostream_pump: read(%s) failed: %s",
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch "iostream_pump: write(%s) failed: %s",
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch http_server_payload_handler_destroy(&conn->payload_handler);
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschvoid http_server_request_forward_payload(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_connection *conn = req->conn;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct istream *input = conn->incoming_payload;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_pump *phandler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch if ((ret = i_stream_get_size(input, TRUE, &payload_size)) != 0) {
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch "i_stream_get_size(%s) failed: %s",
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch i_stream_get_name(input), i_stream_get_error(input));
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch input = i_stream_create_limit(input, max_size);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch phandler = p_new(req->pool, struct http_server_payload_handler_pump, 1);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch http_server_payload_handler_init(&phandler->handler, req);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch phandler->handler.switch_ioloop = payload_handler_pump_switch_ioloop;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch phandler->handler.destroy = payload_handler_pump_destroy;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch phandler->pump = iostream_pump_create(input, output);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch iostream_pump_set_completion_callback(phandler->pump,
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschvoid http_server_request_buffer_payload(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_raw *rhandler =
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch (struct http_server_payload_handler_raw *)handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_raw *rhandler =
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch (struct http_server_payload_handler_raw *)handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch rhandler->io = io_loop_move_io(&rhandler->io);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_raw *rhandler)
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler *handler = &rhandler->handler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_request *req = handler->req;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_connection *conn = req->conn;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct istream *input = conn->incoming_payload;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch req->callback_refcount += req->refcount - old_refcount;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch if (input != NULL && input->stream_errno != 0) {
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch "read(%s) failed: %s",
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch (req->response != NULL && req->response->submitted));
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch http_server_payload_handler_destroy(&conn->payload_handler);
38af46387e565053adf6c47f7f6871676d685de8Stephan Boschvoid http_server_request_handle_payload(struct http_server_request *req,
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch void (*callback)(void *context), void *context)
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_payload_handler_raw *rhandler;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch struct http_server_connection *conn = req->conn;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch rhandler = p_new(req->pool, struct http_server_payload_handler_raw, 1);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch http_server_payload_handler_init(&rhandler->handler, req);
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch rhandler->handler.switch_ioloop = payload_handler_raw_switch_ioloop;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch rhandler->handler.destroy = payload_handler_raw_destroy;
38af46387e565053adf6c47f7f6871676d685de8Stephan Bosch rhandler->io = io_add_istream(conn->incoming_payload,