lib/fetcher: Add version to USER_AGENT string
authorColin Walters <walters@verbum.org>
Wed, 10 Jan 2018 21:02:59 +0000 (16:02 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 11 Jan 2018 14:06:16 +0000 (14:06 +0000)
This came up in allowing Fedora infrastructure to work around a libcurl bug with
HTTP2: https://pagure.io/atomic-wg/issue/405

Closes: https://github.com/ostreedev/ostree/issues/1405
Closes: #1406
Approved by: jlebon

src/libostree/ostree-fetcher-curl.c
src/libostree/ostree-fetcher-soup.c
src/libostree/ostree-fetcher-util.h

index 272d609a6e338b8ef84032912e2cd7ed5b5f853e..2d01257d9a93c4c95443c58c10efbfd44ccc7062 100644 (file)
@@ -714,7 +714,7 @@ initiate_next_curl_request (FetcherRequest *req,
     curl_easy_setopt (req->easy, CURLOPT_URL, uri);
   }
 
-  curl_easy_setopt (req->easy, CURLOPT_USERAGENT, "ostree ");
+  curl_easy_setopt (req->easy, CURLOPT_USERAGENT, OSTREE_FETCHER_USERAGENT_STRING);
   if (self->extra_headers)
     curl_easy_setopt (req->easy, CURLOPT_HTTPHEADER, self->extra_headers);
 
index e023d34e5d495a27f4ca0d9ca9f4e71ccc53e22a..cab8dff6531f209c799c01b26a3d2f2394f22549 100644 (file)
@@ -479,7 +479,7 @@ ostree_fetcher_session_thread (gpointer data)
   g_main_context_push_thread_default (mainctx);
 
   /* We retain ownership of the SoupSession reference. */
-  closure->session = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, "ostree ",
+  closure->session = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, OSTREE_FETCHER_USERAGENT_STRING,
                                                           SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
                                                           SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
                                                           SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_REQUESTER,
index 292938168526f9317afbabad8c02588ce23de8c3..48528e0f4e9bb5cdb93f579ac85f2846710bc42c 100644 (file)
 
 G_BEGIN_DECLS
 
+/* We used to only send "ostree/" but now include the version
+ * https://github.com/ostreedev/ostree/issues/1405
+ * This came up in allowing Fedora infrastructure to work around a libcurl bug with HTTP2.
+ */
+#define OSTREE_FETCHER_USERAGENT_STRING (PACKAGE_NAME "/" PACKAGE_VERSION)
+
 static inline gboolean
 _ostree_fetcher_tmpf_from_flags (OstreeFetcherRequestFlags flags,
                                  int                       dfd,