From 8b6a26170346ccf5d01052229a0618d593b910c5 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Thu, 30 Jul 2015 11:29:27 +0900 Subject: [PATCH] souphttpsrc: handle empty http proxy string 1) If the system http_proxy environment variable is not set or set to an empty string, we must not set proxy to avoid http connection error. 2) In case of proxy property setting, if user want to clear the proxy setting, they should be able to set it to NULL or an empty string again, so this is fixed too. 3) Check if the proxy string was parsed correctly. https://bugzilla.gnome.org/show_bug.cgi?id=752866 --- ext/soup/gstsouphttpsrc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 962ecb1c04..4a270d3f98 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -472,7 +472,7 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src) src->tls_database = DEFAULT_TLS_DATABASE; src->max_retries = DEFAULT_RETRIES; proxy = g_getenv ("http_proxy"); - if (proxy && !gst_soup_http_src_set_proxy (src, proxy)) { + if (!gst_soup_http_src_set_proxy (src, proxy)) { GST_WARNING_OBJECT (src, "The proxy in the http_proxy env var (\"%s\") cannot be parsed.", proxy); @@ -570,11 +570,6 @@ gst_soup_http_src_set_property (GObject * object, guint prop_id, const gchar *proxy; proxy = g_value_get_string (value); - - if (proxy == NULL) { - GST_WARNING ("proxy property cannot be NULL"); - goto done; - } if (!gst_soup_http_src_set_proxy (src, proxy)) { GST_WARNING ("badly formatted proxy URI"); goto done; @@ -2039,6 +2034,10 @@ gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri) soup_uri_free (src->proxy); src->proxy = NULL; } + + if (uri == NULL || *uri == '\0') + return TRUE; + if (g_str_has_prefix (uri, "http://")) { src->proxy = soup_uri_new (uri); } else { @@ -2048,7 +2047,7 @@ gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri) g_free (new_uri); } - return TRUE; + return (src->proxy != NULL); } static guint