From a0f7cde9daa7ed463beee00fb5fe75e8d90fa1d4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 8 Jul 2025 09:56:37 +0200 Subject: dirmngr: Add option--user-agent and always use a User-Agent header. * dirmngr/dirmngr.h (opt): Add user_agent. * dirmngr/dirmngr.c (oUserAgent): New. (opts): Add "user-agent". (parse_rereadable_options): Set option. * dirmngr/ks-engine-hkp.c (send_request): Send User-Agent. * dirmngr/ks-engine-http.c (ks_http_fetch): Ditto. * dirmngr/ocsp.c (do_ocsp_request): Ditto. -- Note that the http_open_document function is not used by dirmngr. If it ever gets used we may want to add a way to configure the http.c module with a user-agent string, so that it is send by the send_request function and we do not need to explictly do that in the caller. GnuPG-bug-id: 7715 --- dirmngr/ks-engine-hkp.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'dirmngr/ks-engine-hkp.c') diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c index 75fe19987..617b01a9f 100644 --- a/dirmngr/ks-engine-hkp.c +++ b/dirmngr/ks-engine-hkp.c @@ -1278,6 +1278,8 @@ send_request (ctrl_t ctrl, const char *request, const char *hostportstr, we're good with both HTTP 1.0 and 1.1. */ es_fputs ("Pragma: no-cache\r\n" "Cache-Control: no-cache\r\n", fp); + if (*opt.user_agent) + es_fprintf (fp, "User-Agent: %s\r\n", opt.user_agent); if (post_cb) err = post_cb (post_cb_value, http); if (!err) -- cgit