souphttpsrc: use version template in user-agent property

Avoids documentation churn when the version changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5090>
This commit is contained in:
Tim-Philipp Müller 2023-08-05 17:27:31 +01:00 committed by GStreamer Marge Bot
parent 8d73b65789
commit e1d4b546c0
2 changed files with 13 additions and 17 deletions

View file

@ -23624,7 +23624,7 @@
"construct": false,
"construct-only": false,
"controllable": false,
"default": "GStreamer souphttpsrc 1.23.0.1 ",
"default": "GStreamer souphttpsrc {VERSION} ",
"mutable": "null",
"readable": true,
"type": "gchararray",

View file

@ -84,6 +84,8 @@
#include <gst/tag/tag.h>
#include <gst/glib-compat-private.h>
/* this is a simple wrapper class around SoupSession; it exists in order to
* have a refcountable owner for the actual SoupSession + the thread it runs
* in and its main loop (we cannot inverse the ownership hierarchy, because
@ -206,7 +208,7 @@ enum
static guint gst_soup_http_src_signals[LAST_SIGNAL] = { 0 };
#define DEFAULT_USER_AGENT "GStreamer souphttpsrc " PACKAGE_VERSION " "
#define DEFAULT_USER_AGENT "GStreamer souphttpsrc {VERSION} "
#define DEFAULT_IRADIO_MODE TRUE
#define DEFAULT_SOUP_LOG_LEVEL SOUP_LOGGER_LOG_HEADERS
#define DEFAULT_COMPRESS FALSE
@ -1762,22 +1764,16 @@ gst_soup_http_src_build_message (GstSoupHTTPSrc * src, const gchar * method)
/* Duplicating the defaults of libsoup here. We don't want to set a
* User-Agent in the session as each source might have its own User-Agent
* set */
if (!src->user_agent || !*src->user_agent) {
gchar *user_agent =
g_strdup_printf ("libsoup/%u.%u.%u", _soup_get_major_version (),
_soup_get_minor_version (), _soup_get_micro_version ());
_soup_message_headers_append (request_headers, "User-Agent", user_agent);
g_free (user_agent);
} else if (g_str_has_suffix (src->user_agent, " ")) {
gchar *user_agent = g_strdup_printf ("%slibsoup/%u.%u.%u", src->user_agent,
_soup_get_major_version (),
_soup_get_minor_version (), _soup_get_micro_version ());
_soup_message_headers_append (request_headers, "User-Agent", user_agent);
g_free (user_agent);
} else {
_soup_message_headers_append (request_headers, "User-Agent",
src->user_agent);
GString *user_agent = g_string_new (src->user_agent);
g_string_replace (user_agent, "{VERSION}", PACKAGE_VERSION, 0);
if (user_agent->len == 0 || g_str_has_suffix (user_agent->str, " ")) {
g_string_append_printf (user_agent, "libsoup/%u.%u.%u",
_soup_get_major_version (), _soup_get_minor_version (),
_soup_get_micro_version ());
}
_soup_message_headers_append (request_headers, "User-Agent", user_agent->str);
g_string_free (user_agent, TRUE);
user_agent = NULL;
if (!src->keep_alive) {
_soup_message_headers_append (request_headers, "Connection", "close");