]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-server-connection - Fix sending of expected 100 Continue response
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 4 Mar 2026 22:53:15 +0000 (23:53 +0100)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Sat, 7 Mar 2026 01:32:16 +0000 (02:32 +0100)
It was never sent when a response was preemptively created but not yet submitted.

src/lib-http/http-server-connection.c
src/lib-http/test-http-payload.c

index 65912a3a553afb15d567396916ad0f9c12203e93..62bdaff4b08fb0825bd51326223bca64b508ab4e 100644 (file)
@@ -324,7 +324,7 @@ http_server_connection_handle_request(struct http_server_connection *conn,
        if (req->req.payload != NULL) {
                /* Send 100 Continue when appropriate */
                if (req->req.expect_100_continue && !req->payload_halted &&
-                   req->response == NULL) {
+                   (req->response == NULL || !req->response->submitted)) {
                        http_server_connection_output_trigger(conn);
                }
 
@@ -781,7 +781,8 @@ http_server_connection_next_response(struct http_server_connection *conn)
                /* send 100 Continue if appropriate */
                if (req->state >= HTTP_SERVER_REQUEST_STATE_QUEUED &&
                    conn->incoming_payload != NULL &&
-                   req->response == NULL && req->req.version_minor >= 1 &&
+                   (req->response == NULL || !req->response->submitted) &&
+                   req->req.version_minor >= 1 &&
                    req->req.expect_100_continue && !req->payload_halted &&
                    !req->sent_100_continue) {
                        static const char *response =
index 2759ceabc03a3b81dd6df0d4d452ccca74c40159..a12708d185763fa4ad2796d2a5e83b104361ca3d 100644 (file)
@@ -66,6 +66,7 @@ static struct test_settings {
        size_t read_server_partial;
        bool server_cork;
        bool server_trickle_final_byte;
+       bool preset_header;
 
        bool ssl;
 } tset;
@@ -754,6 +755,11 @@ client_handle_request(void *context,
 
        creq = client_request_init(client, req);
 
+       if (tset.preset_header) {
+               http_server_request_add_response_header(req,
+                       "X-Dovecot-Test", "Payload");
+       }
+
        if (strcmp(path, "/success") == 0) {
                client_handle_success_request(creq);
                return;
@@ -2076,6 +2082,16 @@ static void test_echo_server_nonblocking_sync(void)
        test_run_pipeline(test_client_echo);
        test_run_parallel(test_client_echo);
        test_end();
+
+       test_begin("http payload echo "
+                  "(server non-blocking; 100-continue; preset header)");
+       test_init_defaults();
+       tset.request_100_continue = TRUE;
+       tset.preset_header = TRUE;
+       test_run_sequential(test_client_echo);
+       test_run_pipeline(test_client_echo);
+       test_run_parallel(test_client_echo);
+       test_end();
 }
 
 static void test_echo_server_blocking_sync(void)