diff options
| author | Dan Winship <danw@gnome.org> | 2013-04-18 10:30:32 -0400 |
|---|---|---|
| committer | Dan Winship <danw@gnome.org> | 2013-04-18 10:30:32 -0400 |
| commit | 8c5ae3c24c95381b52530ac76a80598bb750c1ef (patch) | |
| tree | 7b226a335a961f0bdb7ae1d57659c8b75dbc4542 /libsoup/soup-uri.c | |
| parent | 1498c1a6dcb7f6b9aab93838bc9dfd55fd2a5c59 (diff) | |
| download | libsoup-8c5ae3c24c95381b52530ac76a80598bb750c1ef.tar.gz | |
soup-address: fix proxy enumerator implementation
When creating a GProxyAddressEnumerator, the destination URI passed to
it must include the port number, or the proxy may end up trying to
connect to port 0. libsoup was omitting the port number when it was
the default for the protocol.
https://bugzilla.gnome.org/show_bug.cgi?id=698163
Diffstat (limited to 'libsoup/soup-uri.c')
| -rw-r--r-- | libsoup/soup-uri.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c index 723e3610..26ec24a0 100644 --- a/libsoup/soup-uri.c +++ b/libsoup/soup-uri.c @@ -489,21 +489,9 @@ soup_uri_new (const char *uri_string) } -/** - * soup_uri_to_string: - * @uri: a #SoupURI - * @just_path_and_query: if %TRUE, output just the path and query portions - * - * Returns a string representing @uri. - * - * If @just_path_and_query is %TRUE, this concatenates the path and query - * together. That is, it constructs the string that would be needed in - * the Request-Line of an HTTP request for @uri. - * - * Return value: a string representing @uri, which the caller must free. - **/ char * -soup_uri_to_string (SoupURI *uri, gboolean just_path_and_query) +soup_uri_to_string_internal (SoupURI *uri, gboolean just_path_and_query, + gboolean force_port) { GString *str; char *return_result; @@ -511,7 +499,7 @@ soup_uri_to_string (SoupURI *uri, gboolean just_path_and_query) g_return_val_if_fail (uri != NULL, NULL); g_warn_if_fail (SOUP_URI_IS_VALID (uri)); - str = g_string_sized_new (20); + str = g_string_sized_new (40); if (uri->scheme && !just_path_and_query) g_string_append_printf (str, "%s:", uri->scheme); @@ -527,7 +515,7 @@ soup_uri_to_string (SoupURI *uri, gboolean just_path_and_query) g_string_append_c (str, ']'); } else append_uri_encoded (str, uri->host, ":/"); - if (uri->port && uri->port != soup_scheme_default_port (uri->scheme)) + if (uri->port && (force_port || uri->port != soup_scheme_default_port (uri->scheme))) g_string_append_printf (str, ":%u", uri->port); if (!uri->path && (uri->query || uri->fragment)) g_string_append_c (str, '/'); @@ -558,6 +546,25 @@ soup_uri_to_string (SoupURI *uri, gboolean just_path_and_query) } /** + * soup_uri_to_string: + * @uri: a #SoupURI + * @just_path_and_query: if %TRUE, output just the path and query portions + * + * Returns a string representing @uri. + * + * If @just_path_and_query is %TRUE, this concatenates the path and query + * together. That is, it constructs the string that would be needed in + * the Request-Line of an HTTP request for @uri. + * + * Return value: a string representing @uri, which the caller must free. + **/ +char * +soup_uri_to_string (SoupURI *uri, gboolean just_path_and_query) +{ + return soup_uri_to_string_internal (uri, just_path_and_query, FALSE); +} + +/** * soup_uri_copy: * @uri: a #SoupURI * |
