[gnome-software] fwupd: Use the custom user-agent when downloading firmware



commit 269337e27a044d2b0543bf06a5dd725ad3cff383
Author: Richard Hughes <richard hughsie com>
Date:   Wed Dec 20 12:07:56 2017 +0000

    fwupd: Use the custom user-agent when downloading firmware

 plugins/fwupd/gs-plugin-fwupd.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 08e2aa0..d4e7207 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -102,6 +102,9 @@ void
 gs_plugin_initialize (GsPlugin *plugin)
 {
        GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+#if FWUPD_CHECK_VERSION(1,0,3)
+       g_autofree gchar *user_agent = NULL;
+#endif
        g_autoptr(SoupSession) soup_session = NULL;
 
        priv->client = fwupd_client_new ();
@@ -122,10 +125,18 @@ gs_plugin_initialize (GsPlugin *plugin)
        }
 #endif
 
+#if FWUPD_CHECK_VERSION(1,0,3)
+       /* use a custom user agent to provide the fwupd version */
+       user_agent = fwupd_build_user_agent (PACKAGE_NAME, PACKAGE_VERSION);
+       soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, user_agent,
+                                                     SOUP_SESSION_TIMEOUT, 10,
+                                                     NULL);
+#else
        /* use a custom session with the content decoder turned off */
        soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (),
                                                      SOUP_SESSION_TIMEOUT, 10,
                                                      NULL);
+#endif
        soup_session_remove_feature_by_type (soup_session,
                                             SOUP_TYPE_CONTENT_DECODER);
        gs_plugin_set_soup_session (plugin, soup_session);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]