[libsoup/pgriffis/port-normalized] Remove soup_uri_get_port_with_default()




commit 20cac92959d4e41f448a6d44549d162fb55f46fa
Author: Patrick Griffis <pgriffis igalia com>
Date:   Sat Nov 28 12:04:26 2020 -0600

    Remove soup_uri_get_port_with_default()
    
    The latest GLib handles this for us

 libsoup/auth/soup-auth-digest.c   |  2 +-
 libsoup/hsts/soup-hsts-enforcer.c |  2 +-
 libsoup/soup-connection.c         |  4 ++--
 libsoup/soup-session.c            |  2 +-
 libsoup/soup-uri-utils.c          | 32 ++------------------------------
 5 files changed, 7 insertions(+), 35 deletions(-)
---
diff --git a/libsoup/auth/soup-auth-digest.c b/libsoup/auth/soup-auth-digest.c
index 76922929..adbbffe5 100644
--- a/libsoup/auth/soup-auth-digest.c
+++ b/libsoup/auth/soup-auth-digest.c
@@ -211,7 +211,7 @@ soup_auth_digest_get_protection_space (SoupAuth *auth, GUri *source_uri)
                        uri = g_uri_parse (d, SOUP_HTTP_URI_FLAGS, NULL);
                        if (uri &&
                             g_strcmp0 (g_uri_get_scheme (uri), g_uri_get_scheme (source_uri)) == 0 &&
-                           soup_uri_get_port_with_default (uri) == soup_uri_get_port_with_default 
(source_uri) &&
+                           g_uri_get_port (uri) == g_uri_get_port (source_uri) &&
                            !strcmp (g_uri_get_host (uri), g_uri_get_host (source_uri)))
                                dir = g_strdup (g_uri_get_path (uri));
                        else
diff --git a/libsoup/hsts/soup-hsts-enforcer.c b/libsoup/hsts/soup-hsts-enforcer.c
index 5a297bca..a1e46841 100644
--- a/libsoup/hsts/soup-hsts-enforcer.c
+++ b/libsoup/hsts/soup-hsts-enforcer.c
@@ -495,7 +495,7 @@ rewrite_message_uri_to_https (SoupMessage *msg)
        int port;
 
        uri = soup_message_get_uri (msg);
-       port = soup_uri_get_port_with_default (uri);
+       port = g_uri_get_port (uri);
        /* From the RFC: "If the URI contains an explicit port component that
           is not equal to "80", the port component value MUST be preserved;" */
        if (port == 80)
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index e6a79bf7..c47e962e 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -604,7 +604,7 @@ soup_connection_connect_async (SoupConnection      *conn,
         priv->remote_connectable =
                 g_object_new (G_TYPE_NETWORK_ADDRESS,
                              "hostname", g_uri_get_host (priv->remote_uri),
-                             "port", soup_uri_get_port_with_default (priv->remote_uri),
+                             "port", g_uri_get_port (priv->remote_uri),
                              "scheme", g_uri_get_scheme (priv->remote_uri),
                               NULL);
 
@@ -648,7 +648,7 @@ soup_connection_connect (SoupConnection  *conn,
         priv->remote_connectable =
                g_object_new (G_TYPE_NETWORK_ADDRESS,
                              "hostname", g_uri_get_host (priv->remote_uri),
-                             "port", soup_uri_get_port_with_default (priv->remote_uri),
+                             "port", g_uri_get_port (priv->remote_uri),
                              "scheme", g_uri_get_scheme (priv->remote_uri),
                              NULL);
 
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 296f9d06..c2e1fa55 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -690,7 +690,7 @@ soup_session_host_new (SoupSession *session, GUri *uri)
 
        host->addr = g_object_new (G_TYPE_NETWORK_ADDRESS,
                                   "hostname", g_uri_get_host (host->uri),
-                                  "port", soup_uri_get_port_with_default (host->uri),
+                                  "port", g_uri_get_port (host->uri),
                                   "scheme", g_uri_get_scheme (host->uri),
                                   NULL);
        host->keep_alive_src = NULL;
diff --git a/libsoup/soup-uri-utils.c b/libsoup/soup-uri-utils.c
index fe596a0b..062ed1cc 100644
--- a/libsoup/soup-uri-utils.c
+++ b/libsoup/soup-uri-utils.c
@@ -83,25 +83,6 @@ path_equal (const char *one, const char *two)
        return !strcmp (one, two);
 }
 
-/**
- * soup_uri_get_port_with_default:
- * @uri: A #GUri
- *
- * If @uri has a port of `-1` this will return the default
- * port for the sheme it uses if known.
- *
- * Returns: The port to use with the @uri or `-1` if unknown.
- */
-int
-soup_uri_get_port_with_default (GUri *uri)
-{
-        int port = g_uri_get_port (uri);
-        if (port != -1)
-                return port;
-
-        return soup_scheme_default_port (g_uri_get_scheme (uri));
-}
-
 static gboolean
 flags_equal (GUriFlags flags1, GUriFlags flags2)
 {
@@ -130,7 +111,7 @@ soup_uri_equal (GUri *uri1, GUri *uri2)
 
                if (!flags_equal (g_uri_get_flags (uri1), g_uri_get_flags (uri2))                  ||
             g_strcmp0 (g_uri_get_scheme (uri1), g_uri_get_scheme (uri2))                   ||
-           soup_uri_get_port_with_default (uri1) != soup_uri_get_port_with_default (uri2) ||
+           g_uri_get_port (uri1) != g_uri_get_port (uri2)                                 ||
            !parts_equal (g_uri_get_user (uri1), g_uri_get_user (uri2), FALSE)             ||
            !parts_equal (g_uri_get_password (uri1), g_uri_get_password (uri2), FALSE)     ||
            !parts_equal (g_uri_get_host (uri1), g_uri_get_host (uri2), TRUE)              ||
@@ -234,7 +215,6 @@ soup_uri_host_equal (gconstpointer v1, gconstpointer v2)
        GUri *one = (GUri*)v1;
        GUri *two = (GUri*)v2;
         const char *one_host, *two_host;
-        int one_port, two_port;
 
        g_return_val_if_fail (one != NULL && two != NULL, one == two);
 
@@ -248,15 +228,7 @@ soup_uri_host_equal (gconstpointer v1, gconstpointer v2)
        if (g_strcmp0 (g_uri_get_scheme (one), g_uri_get_scheme (two)) != 0)
                return FALSE;
 
-        one_port = g_uri_get_port (one);
-        two_port = g_uri_get_port (two);
-
-        if (one_port == -1 && g_uri_get_scheme (one))
-                one_port = soup_scheme_default_port (g_uri_get_scheme (one));
-        if (two_port == -1 && g_uri_get_scheme (two))
-                two_port = soup_scheme_default_port (g_uri_get_scheme (two));
-
-       if (one_port != two_port)
+       if (g_uri_get_port (one) != g_uri_get_port (two))
                return FALSE;
 
        return g_ascii_strcasecmp (one_host, two_host) == 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]