[glib: 6/13] gio: replace _g_uri_from_authority() with g_uri_join()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 6/13] gio: replace _g_uri_from_authority() with g_uri_join()
- Date: Wed, 5 Aug 2020 16:06:03 +0000 (UTC)
commit 034a4dcdc06ec0780be8c5be38f3955e1396e542
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Mon Jul 6 23:34:27 2020 +0400
gio: replace _g_uri_from_authority() with g_uri_join()
_g_uri_from_authority() is doing the same work as g_uri_join(): taking
URI components and merging them in a legit URI string, with encoding.
It turns out g_uri_from_authority was unnecessarily complex, since no
caller used the userinfo field.
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
gio/gnetworkaddress.c | 52 ++++++++----------------------------------------
gio/gnetworkingprivate.h | 4 ----
gio/gnetworkservice.c | 12 +++++++----
gio/gsocketaddress.c | 2 +-
4 files changed, 17 insertions(+), 53 deletions(-)
---
diff --git a/gio/gnetworkaddress.c b/gio/gnetworkaddress.c
index f12f93585..9693fc125 100644
--- a/gio/gnetworkaddress.c
+++ b/gio/gnetworkaddress.c
@@ -764,46 +764,6 @@ error:
return FALSE;
}
-gchar *
-_g_uri_from_authority (const gchar *protocol,
- const gchar *host,
- guint port,
- const gchar *userinfo)
-{
- GString *uri;
-
- uri = g_string_new (protocol);
- g_string_append (uri, "://");
-
- if (userinfo)
- {
- g_string_append_uri_escaped (uri, userinfo, G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, FALSE);
- g_string_append_c (uri, '@');
- }
-
- if (g_hostname_is_non_ascii (host))
- {
- gchar *ace_encoded = g_hostname_to_ascii (host);
-
- if (!ace_encoded)
- {
- g_string_free (uri, TRUE);
- return NULL;
- }
- g_string_append (uri, ace_encoded);
- g_free (ace_encoded);
- }
- else if (strchr (host, ':'))
- g_string_append_printf (uri, "[%s]", host);
- else
- g_string_append (uri, host);
-
- if (port != 0)
- g_string_append_printf (uri, ":%u", port);
-
- return g_string_free (uri, FALSE);
-}
-
/**
* g_network_address_parse_uri:
* @uri: the hostname and optionally a port
@@ -1459,10 +1419,14 @@ g_network_address_connectable_proxy_enumerate (GSocketConnectable *connectable)
GSocketAddressEnumerator *proxy_enum;
gchar *uri;
- uri = _g_uri_from_authority (self->priv->scheme ? self->priv->scheme : "none",
- self->priv->hostname,
- self->priv->port,
- NULL);
+ uri = g_uri_join (G_URI_FLAGS_NONE,
+ self->priv->scheme ? self->priv->scheme : "none",
+ NULL,
+ self->priv->hostname,
+ self->priv->port,
+ "",
+ NULL,
+ NULL);
proxy_enum = g_object_new (G_TYPE_PROXY_ADDRESS_ENUMERATOR,
"connectable", connectable,
diff --git a/gio/gnetworkingprivate.h b/gio/gnetworkingprivate.h
index ed0feb823..656379db3 100644
--- a/gio/gnetworkingprivate.h
+++ b/gio/gnetworkingprivate.h
@@ -28,10 +28,6 @@ gboolean _g_uri_parse_authority (const char *uri,
guint16 *port,
char **userinfo,
GError **error);
-gchar * _g_uri_from_authority (const gchar *protocol,
- const gchar *host,
- guint port,
- const gchar *userinfo);
guint64 g_resolver_get_serial (GResolver *resolver);
diff --git a/gio/gnetworkservice.c b/gio/gnetworkservice.c
index 92225f137..2b8571e9b 100644
--- a/gio/gnetworkservice.c
+++ b/gio/gnetworkservice.c
@@ -465,10 +465,14 @@ g_network_service_address_enumerator_next (GSocketAddressEnumerator *enumerator
continue;
}
- uri = _g_uri_from_authority (g_network_service_get_scheme (srv_enum->srv),
- hostname,
- g_srv_target_get_port (target),
- NULL);
+ uri = g_uri_join (G_URI_FLAGS_NONE,
+ g_network_service_get_scheme (srv_enum->srv),
+ NULL,
+ hostname,
+ g_srv_target_get_port (target),
+ "",
+ NULL,
+ NULL);
g_free (hostname);
addr = g_network_address_parse_uri (uri,
diff --git a/gio/gsocketaddress.c b/gio/gsocketaddress.c
index 848e37b0b..2b7e83ccf 100644
--- a/gio/gsocketaddress.c
+++ b/gio/gsocketaddress.c
@@ -398,7 +398,7 @@ g_socket_address_connectable_proxy_enumerate (GSocketConnectable *connectable)
g_object_get (connectable, "address", &addr, "port", &port, NULL);
ip = g_inet_address_to_string (addr);
- uri = _g_uri_from_authority ("none", ip, port, NULL);
+ uri = g_uri_join (G_URI_FLAGS_NONE, "none", NULL, ip, port, "", NULL, NULL);
addr_enum = g_object_new (G_TYPE_PROXY_ADDRESS_ENUMERATOR,
"connectable", connectable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]