]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix support for auth strings and fix ipptool default values bug.
authorMichael R Sweet <msweet@msweet.org>
Wed, 8 Jan 2025 17:32:49 +0000 (12:32 -0500)
committerMichael R Sweet <msweet@msweet.org>
Wed, 8 Jan 2025 17:32:53 +0000 (12:32 -0500)
cups/http.c
tools/ipptool.c

index 009467696f12fcb69be8aa22419e90eecd1cb6aa..0c9803f18f64d4f61debd9d605b6547c7101fa38 100644 (file)
@@ -1,7 +1,7 @@
 //
 // HTTP routines for CUPS.
 //
-// Copyright © 2022-2024 by OpenPrinting.
+// Copyright © 2022-2025 by OpenPrinting.
 // Copyright © 2007-2021 by Apple Inc.
 // Copyright © 1997-2007 by Easy Software Products, all rights reserved.
 //
@@ -2447,6 +2447,8 @@ httpSetAuthString(http_t     *http,       // I - HTTP connection
                  const char *data)     // I - Auth data (NULL for none)
 {
   // Range check input...
+  DEBUG_printf("httpSetAuthString(http=%p, scheme=\"%s\", data=\"%s\")", (void *)http, scheme, data);
+
   if (!http)
     return;
 
@@ -2479,6 +2481,8 @@ httpSetAuthString(http_t     *http,       // I - HTTP connection
     // Clear the current authorization string...
     http->_authstring[0] = '\0';
   }
+
+  DEBUG_printf("1httpSetAuthString: authstring=\"%s\"", http->authstring);
 }
 
 
@@ -4187,6 +4191,10 @@ http_send(http_t       *http,            // I - HTTP connection
   if (!http->fields[HTTP_FIELD_ACCEPT_ENCODING] && http->default_fields[HTTP_FIELD_ACCEPT_ENCODING])
     httpSetField(http, HTTP_FIELD_ACCEPT_ENCODING, http->default_fields[HTTP_FIELD_ACCEPT_ENCODING]);
 
+  // Set the Authorization field if it isn't already...
+  if (!http->fields[HTTP_FIELD_AUTHORIZATION] && http->authstring)
+    httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring);
+
   // Encode the URI as needed...
   _httpEncodeURI(buf, uri, sizeof(buf));
 
index fc15dce8d1c2f4472ca2e3f5d5be71e844d13e29..228820ddf11aa2df142441646a2b8dfc97e3e0b3 100644 (file)
@@ -1,7 +1,7 @@
 //
 // ipptool command for CUPS.
 //
-// Copyright © 2020-2024 by OpenPrinting.
+// Copyright © 2020-2025 by OpenPrinting.
 // Copyright © 2020 by The Printer Working Group.
 // Copyright © 2007-2021 by Apple Inc.
 // Copyright © 1997-2007 by Easy Software Products.
@@ -999,9 +999,9 @@ connect_printer(ipptool_test_t *data)       // I - Test data
   }
 
   if (data->bearer_token)
-    httpSetAuthString(data->http, "Bearer", data->bearer_token);
+    httpSetAuthString(http, "Bearer", data->bearer_token);
 
-  httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
+  httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
 
   if (data->timeout > 0.0)
     httpSetTimeout(http, data->timeout, timeout_cb, NULL);