From: Michael R Sweet Date: Thu, 18 Sep 2025 15:14:22 +0000 (-0400) Subject: Add a --user-agent option to the ipptool command. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23dec7fbdd5d87ba5e021ff4fe32ed9b19a60c5e;p=thirdparty%2Fcups.git Add a --user-agent option to the ipptool command. --- diff --git a/CHANGES.md b/CHANGES.md index 72b60d895b..9a5bf0c458 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -40,6 +40,7 @@ Changes in CUPS v2.5b1 (YYYY-MM-DD) not specified (Issue #1217) - Added `print-as-raster` printer and job attributes for forcing rasterization (Issue #1282) +- Added a "--user-agent" option to the `ipptool` command. - Updated documentation (Issue #984, Issue #1086, Issue #1182) - Updated translations (Issue #1146, Issue #1161, Issue #1164) - Updated the configure script to default to installing to /usr/local. diff --git a/doc/help/man-ipptool.html b/doc/help/man-ipptool.html index 0882b391dd..ed25bfd778 100644 --- a/doc/help/man-ipptool.html +++ b/doc/help/man-ipptool.html @@ -25,6 +25,9 @@ ] [ --stop-after-include-error ] [ +--user-agent +USER-AGENT +] [ --version ] [ -4 @@ -125,6 +128,15 @@ Tells to stop if an error occurs in an included file. Normally ipptool will continue with subsequent tests after the INCLUDE directive. +

+

--user-agent USER-AGENT
+Specifies the HTTP User-Agent string to use. +The default is based on the +UserAgentTokens +value in the +client.conf(5) + +file.

--version
Shows the version of @@ -308,13 +320,15 @@ program is unique to CUPS and conforms to the Internet Printing Protocol up to v ipp://localhost/printers/myprinter create-printer-subscription.test

See Also

-

ipptoolfile(5), +

client.conf(5), + +ipptoolfile(5), IANA IPP Registry (https://www.iana.org/assignments/ipp-registrations), PWG Internet Printing Protocol Workgroup (https://www.pwg.org/ipp), RFC 8011 (https://datatracker.ietf.org/doc/html/rfc8011)

Copyright

-

Copyright © 2021-2024 by OpenPrinting. +

Copyright © 2021-2025 by OpenPrinting. diff --git a/man/ipptool.1 b/man/ipptool.1 index 7731aa5c2b..22c3f846cf 100644 --- a/man/ipptool.1 +++ b/man/ipptool.1 @@ -7,7 +7,7 @@ .\" Licensed under Apache License v2.0. See the file "LICENSE" for more .\" information. .\" -.TH ipptool 1 "CUPS" "2025-04-30" "OpenPrinting" +.TH ipptool 1 "CUPS" "2025-09-18" "OpenPrinting" .SH NAME ipptool \- perform internet printing protocol requests .SH SYNOPSIS @@ -26,6 +26,9 @@ ipptool \- perform internet printing protocol requests ] [ .B \-\-stop\-after\-include\-error ] [ +.B \-\-user\-agent +.I USER-AGENT +] [ .B \-\-version ] [ .B \-4 @@ -123,6 +126,14 @@ to stop if an error occurs in an included file. Normally .B ipptool will continue with subsequent tests after the INCLUDE directive. .TP 5 +\fB\-\-user\-agent \fIUSER-AGENT\fR +Specifies the HTTP User-Agent string to use. +The default is based on the +.B UserAgentTokens +value in the +.BR client.conf (5) +file. +.TP 5 .B \-\-version Shows the version of .B ipptool @@ -297,9 +308,10 @@ Send email notifications to "user@example.com" when "myprinter" changes: ipp://localhost/printers/myprinter create\-printer\-subscription.test .fi .SH SEE ALSO +.BR client.conf (5), .BR ipptoolfile (5), IANA IPP Registry (https://www.iana.org/assignments/ipp\-registrations), PWG Internet Printing Protocol Workgroup (https://www.pwg.org/ipp), RFC 8011 (https://datatracker.ietf.org/doc/html/rfc8011) .SH COPYRIGHT -Copyright \[co] 2021-2024 by OpenPrinting. +Copyright \[co] 2021-2025 by OpenPrinting. diff --git a/tools/ipptool.c b/tools/ipptool.c index c8f58a58e3..f44b4779ec 100644 --- a/tools/ipptool.c +++ b/tools/ipptool.c @@ -149,7 +149,8 @@ typedef struct ipptool_test_s // Test Data int verbosity; // Show all attributes? char *bearer_token, // HTTP Bearer token - *client_name; // TLS client certificate name + *client_name, // TLS client certificate name + *user_agent; // HTTP User-Agent value, if any // Test Defaults bool def_ignore_errors; // Default IGNORE-ERRORS value @@ -371,6 +372,19 @@ main(int argc, // I - Number of command-line args { data->stop_after_include_error = 1; } + else if (!strcmp(argv[i], "--user-agent")) + { + i ++; + + if (i >= argc) + { + _cupsLangPrintf(stderr, _("%s: Missing user agent after '--user-agent'."), "ipptool"); + free_data(data); + usage(); + } + + data->user_agent = argv[i]; + } else if (!strcmp(argv[i], "--version")) { puts(CUPS_SVERSION); @@ -1003,6 +1017,9 @@ connect_printer(ipptool_test_t *data) // I - Test data httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity"); + if (data->user_agent) + httpSetDefaultField(http, HTTP_FIELD_USER_AGENT, data->user_agent); + if (data->timeout > 0.0) httpSetTimeout(http, data->timeout, timeout_cb, NULL); @@ -6509,6 +6526,7 @@ usage(void) _cupsLangPuts(stderr, _("--ippserver filename Produce ippserver attribute file")); _cupsLangPuts(stderr, _("--stop-after-include-error\n" " Stop tests after a failed INCLUDE")); + _cupsLangPuts(stderr, _("--user-agent USER-AGENT Set the HTTP User-Agent string")); _cupsLangPuts(stderr, _("--version Show version")); _cupsLangPuts(stderr, _("-4 Connect using IPv4")); _cupsLangPuts(stderr, _("-6 Connect using IPv6"));