]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add a --user-agent option to the ipptool command.
authorMichael R Sweet <msweet@msweet.org>
Thu, 18 Sep 2025 15:14:22 +0000 (11:14 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 18 Sep 2025 15:14:26 +0000 (11:14 -0400)
CHANGES.md
doc/help/man-ipptool.html
man/ipptool.1
tools/ipptool.c

index 72b60d895bd2b151d53562ac7b9bfdd767d3feb1..9a5bf0c458fce734d4dca8cf7ae8bcba80b1abd8 100644 (file)
@@ -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.
index 0882b391ddd8e2a7f3370418afbc1b37aea321ac..ed25bfd7788184b7dcbde04b3afa1b4506165ec3 100644 (file)
@@ -25,6 +25,9 @@
 ] [
 <strong>--stop-after-include-error</strong>
 ] [
+<strong>--user-agent</strong>
+<em>USER-AGENT</em>
+] [
 <strong>--version</strong>
 ] [
 <strong>-4</strong>
@@ -125,6 +128,15 @@ Tells
 to stop if an error occurs in an included file. Normally
 <strong>ipptool</strong>
 will continue with subsequent tests after the INCLUDE directive.
+</p>
+    <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>--user-agent </strong><em>USER-AGENT</em><br>
+Specifies the HTTP User-Agent string to use.
+The default is based on the
+<strong>UserAgentTokens</strong>
+value in the
+<a href="client.conf.html"><strong>client.conf</strong>(5)</a>
+
+file.
 </p>
     <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>--version</strong><br>
 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
 </pre>
     <h2 id="ipptool-1.see-also">See Also</h2>
-<a href="ipptoolfile.html"><p><strong>ipptoolfile</strong>(5),</a>
+<a href="client.conf.html"><p><strong>client.conf</strong>(5),</a>
+
+<a href="ipptoolfile.html"><strong>ipptoolfile</strong>(5),</a>
 
 IANA IPP Registry (<a href="https://www.iana.org/assignments/ipp-registrations">https://www.iana.org/assignments/ipp-registrations</a>),
 PWG Internet Printing Protocol Workgroup (<a href="https://www.pwg.org/ipp">https://www.pwg.org/ipp</a>),
 RFC 8011 (<a href="https://datatracker.ietf.org/doc/html/rfc8011">https://datatracker.ietf.org/doc/html/rfc8011</a>)
 </p>
     <h2 id="ipptool-1.copyright">Copyright</h2>
-<p>Copyright &copy; 2021-2024 by OpenPrinting.
+<p>Copyright &copy; 2021-2025 by OpenPrinting.
   </body>
 </html>
index 7731aa5c2bdffabf3cc3974fe96054a409867337..22c3f846cfbf32ab3501078a963f38eff583ce56 100644 (file)
@@ -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.
index c8f58a58e3df6139b5361d1c0845db7d80d59394..f44b4779ec1d30b347090e02c707cdd84ca6c715 100644 (file)
@@ -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"));