static void http_server_connection_request_callback(
struct http_server_connection *conn, struct http_server_request *req)
{
- unsigned int old_refcount = req->refcount;
-
/* CONNECT method */
if (strcmp(req->req.method, "CONNECT") == 0) {
if (conn->callbacks->handle_connect_request == NULL) {
}
conn->callbacks->handle_request(conn->context, req);
}
-
- i_assert((req->response != NULL &&
- req->response->submitted) ||
- req->refcount > old_refcount);
}
static bool
struct http_server_request *req)
{
const struct http_server_settings *set = &conn->server->set;
+ unsigned int old_refcount, new_refcount;
struct istream *payload;
+ bool payload_destroyed = FALSE;
i_assert(!conn->in_req_callback);
i_assert(conn->incoming_payload == NULL);
our one before calling it */
http_server_connection_input_halt(conn);
+ old_refcount = req->refcount;
conn->in_req_callback = TRUE;
http_server_connection_request_callback(conn, req);
if (conn->closed) {
return FALSE;
}
conn->in_req_callback = FALSE;
+ new_refcount = req->refcount;
if (req->req.payload != NULL) {
/* send 100 Continue when appropriate */
if (conn->to_input != NULL) {
/* already finished reading the payload */
http_server_payload_finished(conn);
+ payload_destroyed = TRUE;
}
}
http_server_request_submit_response(req);
}
+ i_assert(!payload_destroyed ||
+ new_refcount > old_refcount ||
+ (req->response != NULL && req->response->submitted));
+
if (conn->incoming_payload == NULL) {
if (conn->conn.io == NULL && conn->to_input == NULL)
http_server_connection_input_resume(conn);
The response is sent either with http_server_request_fail*() or
http_server_response_submit*(). For simple requests you can send the
response back immediately. If you can't do that, you'll need to
- reference the request. Then the code flow usually goes like this:
+ reference the request (or the request payload input stream). Then the
+ code flow usually goes like this:
- http_server_request_set_destroy_callback(destroy_callback)
- http_server_request_ref()