]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Use localhost host header for loopback/domain sockets (Issue #185)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 26 May 2021 22:43:19 +0000 (18:43 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 26 May 2021 22:43:19 +0000 (18:43 -0400)
CHANGES.md
cups/http.c

index 29faad9de32f56eabc26c06486c4c415aa1af875..5d99e6a3ca53fbe276c107d1081eac2758fd74c8 100644 (file)
@@ -42,6 +42,8 @@ CUPS v2.4rc1 (Pending)
 - Now use a 60 second timeout for reading USB backchannel data (Issue #160)
 - The USB backend now tries harder to find a serial number (Issue #170)
 - Fixed `@IF(name)` handling in `cupsd.conf` (Apple #5918)
+- Now always pass "localhost" in the `Host:` header when talking over a domain
+  socket or the loopback interface (Issue #185)
 - Fixed a job history update issue in the scheduler (Issue #187)
 - Fixed `job-pages-per-set` value for duplex print jobs.
 - Documentation fixes (Issue #92, Issue #163, Issue #177, Issue #184)
index f7331036d0db2a107e5d1dd348761443e70ce6bc..15881aed0b4e0189b6fcfa10e70b998567ea5881 100644 (file)
@@ -4402,14 +4402,19 @@ http_send(http_t       *http,           /* I - HTTP connection */
   }
 
   for (i = 0; i < HTTP_FIELD_MAX; i ++)
+  {
     if ((value = httpGetField(http, i)) != NULL && *value)
     {
       DEBUG_printf(("5http_send: %s: %s", http_fields[i], value));
 
       if (i == HTTP_FIELD_HOST)
       {
-       if (httpPrintf(http, "Host: %s:%d\r\n", value,
-                      httpAddrPort(http->hostaddr)) < 1)
+        // Issue #185: Use "localhost" for the loopback addresses to work
+        // around an Avahi bug...
+        if (httpAddrLocalhost(http->hostaddr))
+          value = "localhost";
+
+       if (httpPrintf(http, "Host: %s:%d\r\n", value, httpAddrPort(http->hostaddr)) < 1)
        {
          http->status = HTTP_STATUS_ERROR;
          return (-1);
@@ -4421,6 +4426,7 @@ http_send(http_t       *http,             /* I - HTTP connection */
        return (-1);
       }
     }
+  }
 
   if (http->cookie)
     if (httpPrintf(http, "Cookie: $Version=0; %s\r\n", http->cookie) < 1)