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
This commit is contained in:
Eunhae Choi 2015-07-30 11:29:27 +09:00 committed by Tim-Philipp Müller
parent 0968487071
commit 8b6a261703

View file

@ -472,7 +472,7 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src)
src->tls_database = DEFAULT_TLS_DATABASE; src->tls_database = DEFAULT_TLS_DATABASE;
src->max_retries = DEFAULT_RETRIES; src->max_retries = DEFAULT_RETRIES;
proxy = g_getenv ("http_proxy"); 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, GST_WARNING_OBJECT (src,
"The proxy in the http_proxy env var (\"%s\") cannot be parsed.", "The proxy in the http_proxy env var (\"%s\") cannot be parsed.",
proxy); proxy);
@ -570,11 +570,6 @@ gst_soup_http_src_set_property (GObject * object, guint prop_id,
const gchar *proxy; const gchar *proxy;
proxy = g_value_get_string (value); 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)) { if (!gst_soup_http_src_set_proxy (src, proxy)) {
GST_WARNING ("badly formatted proxy URI"); GST_WARNING ("badly formatted proxy URI");
goto done; goto done;
@ -2039,6 +2034,10 @@ gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri)
soup_uri_free (src->proxy); soup_uri_free (src->proxy);
src->proxy = NULL; src->proxy = NULL;
} }
if (uri == NULL || *uri == '\0')
return TRUE;
if (g_str_has_prefix (uri, "http://")) { if (g_str_has_prefix (uri, "http://")) {
src->proxy = soup_uri_new (uri); src->proxy = soup_uri_new (uri);
} else { } else {
@ -2048,7 +2047,7 @@ gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri)
g_free (new_uri); g_free (new_uri);
} }
return TRUE; return (src->proxy != NULL);
} }
static guint static guint