Skip to content

Commit

Permalink
Fix support for auth strings and fix ipptool default values bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Jan 8, 2025
1 parent 8ef9f9b commit 8f2bed7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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 © 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.
//
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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));

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 © 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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8f2bed7

Please sign in to comment.