[libsoup] Revert "Readd soup_uri_get_host_for_headers()"



commit fece14684762f13cf2f272d066ab73fac7b8b697
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Thu Dec 10 11:00:11 2020 +0100

    Revert "Readd soup_uri_get_host_for_headers()"
    
    This reverts commit bdf52faffe2258fb93a5d07ee1b2750d005a0c36.

 libsoup/soup-logger.c            | 10 ++++++++--
 libsoup/soup-message-io.c        | 11 ++++++++---
 libsoup/soup-uri-utils-private.h |  2 --
 libsoup/soup-uri-utils.c         | 13 -------------
 4 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index caa409dc..ed18fc12 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -516,14 +516,20 @@ print_request (SoupLogger *logger, SoupMessage *msg,
                return;
 
        if (!soup_message_headers_get_one (soup_message_get_request_headers (msg), "Host")) {
-               char *uri_host = soup_uri_get_host_for_headers (uri);
+               char *uri_host = (char*)g_uri_get_host (uri);
+
+               if (strchr (uri_host, ':'))
+                       uri_host = g_strdup_printf ("[%s]", uri_host);
+               else if (g_hostname_is_non_ascii (uri_host))
+                       uri_host = g_hostname_to_ascii (uri_host);
 
                soup_logger_print (logger, SOUP_LOGGER_LOG_HEADERS, '>',
                                   "Host: %s%c%u", uri_host,
                                   soup_uri_uses_default_port (uri) ? '\0' : ':',
                                   g_uri_get_port (uri));
 
-               g_free (uri_host);
+               if (uri_host != g_uri_get_host (uri))
+                       g_free (uri_host);
        }
        soup_message_headers_iter_init (&iter, soup_message_get_request_headers (msg));
        while (soup_message_headers_iter_next (&iter, &name, &value)) {
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index 4ca638c0..1055c099 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -259,12 +259,16 @@ write_headers (SoupMessage          *msg,
               SoupEncoding         *encoding)
 {
        GUri *uri = soup_message_get_uri (msg);
-        char *uri_host;
+       char *uri_host;
        char *uri_string;
        SoupMessageHeadersIter iter;
        const char *name, *value;
 
-        uri_host = soup_uri_get_host_for_headers (uri);
+        uri_host = (char*)g_uri_get_host (uri);
+       if (strchr (uri_host, ':'))
+               uri_host = g_strdup_printf ("[%.*s]", (int) strcspn (uri_host, "%"), uri_host);
+       else if (g_hostname_is_non_ascii (uri_host))
+               uri_host = g_hostname_to_ascii (uri_host);
 
        if (soup_message_get_method (msg) == SOUP_METHOD_CONNECT) {
                /* CONNECT URI is hostname:port for tunnel destination */
@@ -304,7 +308,8 @@ write_headers (SoupMessage          *msg,
                }
        }
        g_free (uri_string);
-       g_free (uri_host);
+       if (uri_host != g_uri_get_host (uri))
+               g_free (uri_host);
 
        *encoding = soup_message_headers_get_encoding (soup_message_get_request_headers (msg));
 
diff --git a/libsoup/soup-uri-utils-private.h b/libsoup/soup-uri-utils-private.h
index 6bc2b38d..b741a6d7 100644
--- a/libsoup/soup-uri-utils-private.h
+++ b/libsoup/soup-uri-utils-private.h
@@ -28,8 +28,6 @@ gboolean     soup_uri_host_equal            (gconstpointer v1, gconstpointer v2)
 
 GUri        *soup_uri_copy_with_normalized_flags (GUri  *uri);
 
-char        *soup_uri_get_host_for_headers  (GUri       *uri);
-
 #define SOUP_URI_IS_VALID(x) (x && g_uri_get_host(x) && g_uri_get_host(x)[0])
 
 G_END_DECLS
diff --git a/libsoup/soup-uri-utils.c b/libsoup/soup-uri-utils.c
index de4a162a..4bc4c11c 100644
--- a/libsoup/soup-uri-utils.c
+++ b/libsoup/soup-uri-utils.c
@@ -489,16 +489,3 @@ soup_uri_copy_with_normalized_flags (GUri *uri)
                 g_uri_get_fragment (uri)
         );
 }
-
-char *
-soup_uri_get_host_for_headers (GUri *uri)
-{
-        const char *host = g_uri_get_host (uri);
-
-        if (strchr (host, ':'))
-                return g_strdup_printf ("[%.*s]", (int)strcspn (host, "%"), host);
-        if (g_hostname_is_non_ascii (host))
-                return g_hostname_to_ascii (host);
-
-        return g_strdup (host);
-}


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