From: Michael R Sweet Date: Wed, 8 Jan 2025 17:32:49 +0000 (-0500) Subject: Fix support for auth strings and fix ipptool default values bug. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f2bed7cbf664a49466ba44cdca627f7f640298b;p=thirdparty%2Fcups.git Fix support for auth strings and fix ipptool default values bug. --- diff --git a/cups/http.c b/cups/http.c index 009467696f..0c9803f18f 100644 --- a/cups/http.c +++ b/cups/http.c @@ -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)); diff --git a/tools/ipptool.c b/tools/ipptool.c index fc15dce8d1..228820ddf1 100644 --- a/tools/ipptool.c +++ b/tools/ipptool.c @@ -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);