]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
scheduler: Fix sending response headers to client
authorZdenek Dohnal <zdohnal@redhat.com>
Fri, 5 Apr 2024 08:46:22 +0000 (10:46 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Fri, 5 Apr 2024 08:46:22 +0000 (10:46 +0200)
Sometimes headers are not correctly copied into response to the client (some are missing). It happens because sent_header is set prematurely before the actual send happens. The present code in affected cupsdWriteClient() scope looks like code remains from CUPS 1.6.3, where cupsdSendHeader() is called earlier and generates the required headers by itself - the current cupsdSendHeader() sends only the headers which are saved in array fields, so the premature setting of sent_header sometimes causes not having all headers in the response.

With the change, testing via curl gives reliable results all time.

CHANGES.md
scheduler/client.c

index 9b47f2b34179ed61361a7ae336616e84b40cce3b..edbd0bbf8d108af123130d2d158b036f400915a1 100644 (file)
@@ -35,6 +35,7 @@ Changes in CUPS v2.4.8 (TBA)
 - Fixed `httpGets` timeout handling (Issue #879)
 - Fixed checking for required attributes during PPD generation (Issue #890)
 - Fixed encoding of IPv6 addresses in HTTP requests (Issue #903)
+- Fixed sending response headers to client (Issue #927)
 - Fixed CGI program initialization and validation of form checkbox and text
   fields.
 
index a2f53744ceb5ef4f5f3a20f256ef6e152731d8fa..c13cfbfa58d8adbf1dc8437b54913a602500e419 100644 (file)
@@ -2427,23 +2427,12 @@ cupsdWriteClient(cupsd_client_t *con)   /* I - Client connection */
              httpSetField(con->http, field, value);
 
              if (field == HTTP_FIELD_LOCATION)
-             {
                con->pipe_status = HTTP_STATUS_SEE_OTHER;
-               con->sent_header = 2;
-             }
-             else
-               con->sent_header = 1;
            }
            else if (!_cups_strcasecmp(con->header, "Status") && value)
-           {
              con->pipe_status = (http_status_t)atoi(value);
-             con->sent_header = 2;
-           }
            else if (!_cups_strcasecmp(con->header, "Set-Cookie") && value)
-           {
              httpSetCookie(con->http, value);
-             con->sent_header = 1;
-           }
          }
 
          /*
@@ -2478,6 +2467,8 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
                cupsdCloseClient(con);
                return;
              }
+
+             con->sent_header = 1;
            }
            else
            {
@@ -2486,6 +2477,8 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
                cupsdCloseClient(con);
                return;
              }
+
+             con->sent_header = 1;
            }
           }
          else