From 902b38d33a9761eba12c6a53e13c6fb89a167b39 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 14 Mar 2008 23:10:57 +0000 Subject: [PATCH] Fix Host header syntax when the host is an IPv6 address literal. Noticed * libsoup/soup-message-client-io.c (get_request_headers): Fix Host header syntax when the host is an IPv6 address literal. Noticed while poking at #522519. svn path=/trunk/; revision=1109 --- ChangeLog | 6 ++++++ libsoup/soup-message-client-io.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5579a5..4eef5e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-03-14 Dan Winship + * libsoup/soup-message-client-io.c (get_request_headers): Fix Host + header syntax when the host is an IPv6 address literal. Noticed + while poking at #522519. + +2008-03-14 Dan Winship + * libsoup/soup-message-private.h (SoupMessagePrivate): add an orig_http_version field. diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c index 4ffbd72..4906f64 100644 --- a/libsoup/soup-message-client-io.c +++ b/libsoup/soup-message-client-io.c @@ -66,13 +66,19 @@ get_request_headers (SoupMessage *req, GString *header, SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req); gboolean proxy = GPOINTER_TO_UINT (user_data); SoupURI *uri = soup_message_get_uri (req); + char *uri_host; char *uri_string; SoupMessageHeadersIter iter; const char *name, *value; + if (strchr (uri->host, ':')) + uri_host = g_strdup_printf ("[%s]", uri->host); + else + uri_host = uri->host; + if (req->method == SOUP_METHOD_CONNECT) { /* CONNECT URI is hostname:port for tunnel destination */ - uri_string = g_strdup_printf ("%s:%d", uri->host, uri->port); + uri_string = g_strdup_printf ("%s:%d", uri_host, uri->port); } else { /* Proxy expects full URI to destination. Otherwise * just the path. @@ -88,13 +94,15 @@ get_request_headers (SoupMessage *req, GString *header, req->method, uri_string); if (soup_uri_uses_default_port (uri)) { g_string_append_printf (header, "Host: %s\r\n", - uri->host); + uri_host); } else { g_string_append_printf (header, "Host: %s:%d\r\n", - uri->host, uri->port); + uri_host, uri->port); } } g_free (uri_string); + if (uri_host != uri->host) + g_free (uri_host); *encoding = soup_message_headers_get_encoding (req->request_headers); if (*encoding != SOUP_ENCODING_CHUNKED && -- 2.7.4