]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
scheduler: Fix sending response headers to client 927/head
authorZdenek Dohnal <zdohnal@redhat.com>
Wed, 3 Apr 2024 08:39:24 +0000 (10:39 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Wed, 3 Apr 2024 08:39:24 +0000 (10:39 +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.

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

scheduler/client.c

index 62ac21c69812bbc1bc732a886c7cf677fb41e9aa..e7e312b8ef1e5a237fee1f51db53e909c62d49d3 100644 (file)
@@ -2400,23 +2400,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;
-           }
          }
 
          /*
@@ -2451,6 +2440,8 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
                cupsdCloseClient(con);
                return;
              }
+
+             con->sent_header = 1;
            }
            else
            {
@@ -2459,6 +2450,8 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
                cupsdCloseClient(con);
                return;
              }
+
+             con->sent_header = 1;
            }
           }
          else