[gnome-online-accounts/gnome-3-18] owncloud: Set the correct port number in GoaFiles:Uri
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/gnome-3-18] owncloud: Set the correct port number in GoaFiles:Uri
- Date: Thu, 1 Oct 2015 16:38:41 +0000 (UTC)
commit 5d5d8028274f9cb49ca77d9fb2cfe8b8ba382b3f
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Sep 11 19:54:30 2015 +0200
owncloud: Set the correct port number in GoaFiles:Uri
Thing is that soup_uri_set_scheme has the side-effect of setting the
port to the default port for the specified scheme. Therefore when we
change http(s) to dav(s) we lose the non-standard port, if any. We
need to save the original port number and set it again.
Also, it is cleaner to use a temporary copy than modifying the
original object. Unintended side-effects like this will be contained
within the function and not be leaked to the caller.
https://bugzilla.gnome.org/show_bug.cgi?id=752736
src/goabackend/goaowncloudprovider.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index 0e46132..05a98ad 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -103,20 +103,28 @@ uri_to_string_with_path (SoupURI *soup_uri, const gchar *path)
static char *get_webdav_uri (SoupURI *soup_uri)
{
+ SoupURI *uri_tmp;
gchar *uri_webdav;
const gchar *scheme;
+ guint port;
if (soup_uri == NULL)
return NULL;
scheme = soup_uri_get_scheme (soup_uri);
+ port = soup_uri_get_port (soup_uri);
+ uri_tmp = soup_uri_copy (soup_uri);
+
if (g_strcmp0 (scheme, SOUP_URI_SCHEME_HTTPS) == 0)
- soup_uri_set_scheme (soup_uri, "davs");
+ soup_uri_set_scheme (uri_tmp, "davs");
else
- soup_uri_set_scheme (soup_uri, "dav");
- uri_webdav = uri_to_string_with_path (soup_uri, WEBDAV_ENDPOINT);
- /* restore initial scheme */
- soup_uri_set_scheme (soup_uri, scheme);
+ soup_uri_set_scheme (uri_tmp, "dav");
+
+ if (!soup_uri_uses_default_port (soup_uri))
+ soup_uri_set_port (uri_tmp, port);
+
+ uri_webdav = uri_to_string_with_path (uri_tmp, WEBDAV_ENDPOINT);
+ soup_uri_free (uri_tmp);
return uri_webdav;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]