[libgweather/wip/hadess/app-id: 4/10] gweather: Set the HTTP user-agent using the application-id




commit c11ee04fd482f154f2961eed8ea607e1b42d7377
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 12 12:04:09 2021 +0100

    gweather: Set the HTTP user-agent using the application-id

 libgweather/gweather-weather.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c
index c505ccdd..2ae8af48 100644
--- a/libgweather/gweather-weather.c
+++ b/libgweather/gweather-weather.c
@@ -622,10 +622,11 @@ dump_and_unref_cache (SoupCache *cache)
 static SoupSession *static_session;
 
 static SoupSession *
-ref_session (void)
+ref_session (GWeatherInfo *info)
 {
     SoupSession *session;
     SoupCache *cache;
+    g_autofree char *user_agent = NULL;
 
     session = static_session;
 
@@ -633,8 +634,9 @@ ref_session (void)
        return g_object_ref (session);
 
     session = soup_session_new ();
-    g_object_set (G_OBJECT (session), SOUP_SESSION_USER_AGENT,
-                  "libgweather/" LIBGWEATHER_VERSION " (+https://gitlab.gnome.org/GNOME/libgweather/) ", 
NULL);
+    user_agent = g_strdup_printf ("libgweather/%s (+https://gitlab.gnome.org/GNOME/libgweather/) %s",
+                                  LIBGWEATHER_VERSION, info->application_id);
+    g_object_set (G_OBJECT (session), SOUP_SESSION_USER_AGENT, user_agent, NULL);
 
     cache = get_cache ();
     if (cache != NULL) {
@@ -703,7 +705,7 @@ gweather_info_update (GWeatherInfo *info)
     gweather_info_reset (info);
 
     if (!info->session)
-       info->session = ref_session ();
+       info->session = ref_session (info);
 
     if (info->providers & GWEATHER_PROVIDER_METAR)
        metar_start_open (info);


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