Skip to content

Commit

Permalink
Fix handling of default auth strings and defaults in ipptool.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Jan 8, 2025
1 parent b3dfe6a commit 1c1c8c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ libcups v3.0rc4 (YYYY-MM-DD)
`ippeveprinter` tool (Issue #95)
- Fixed a duplicate printer reporting bug in `cupsGetDests`.
- Fixed handling of `NULL` path in `cupsSaveCredentials` API.
- Fixed handling of default authorization strings.


libcups v3.0rc3 (2024-10-22)
Expand Down
10 changes: 9 additions & 1 deletion cups/http.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// HTTP routines for CUPS.
//
// Copyright © 2021-2024 by OpenPrinting.
// Copyright © 2021-2025 by OpenPrinting.
// Copyright © 2007-2021 by Apple Inc.
// Copyright © 1997-2007 by Easy Software Products, all rights reserved.
//
Expand Down Expand Up @@ -2044,6 +2044,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;

Expand All @@ -2067,6 +2069,8 @@ httpSetAuthString(http_t *http, // I - HTTP connection
// Clear the current authorization string...
http->authstring = NULL;
}

DEBUG_printf("1httpSetAuthString: authstring=\"%s\"", http->authstring);
}


Expand Down Expand Up @@ -3754,6 +3758,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));

Expand Down
6 changes: 3 additions & 3 deletions tools/ipptool.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// ipptool command for CUPS.
//
// Copyright © 2021-2024 by OpenPrinting.
// Copyright © 2021-2025 by OpenPrinting.
// Copyright © 2020 by The Printer Working Group.
// Copyright © 2007-2021 by Apple Inc.
// Copyright © 1997-2007 by Easy Software Products.
Expand Down Expand Up @@ -1051,9 +1051,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);
Expand Down

0 comments on commit 1c1c8c5

Please sign in to comment.