diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-01-12 12:04:09 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-01-12 13:29:59 +0100 |
commit | f9b16f23253570055da8a15aaf14bb7dfe5aa1d0 (patch) | |
tree | 646b58e7acd7ad72d5fc41b53de802ca92de288c | |
parent | 6200df7ae4644d7cef01b726d71a84fdfb08af04 (diff) | |
download | libgweather-f9b16f23253570055da8a15aaf14bb7dfe5aa1d0.tar.gz |
gweather: Set the HTTP user-agent using the application-id
-rw-r--r-- | libgweather/gweather-weather.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c index 7fcba5b..37ee928 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); |