soup-message-client-io: add a Host header to HTTP/1.0 messages too
authorDan Winship <danw@gnome.org>
Sat, 17 Nov 2012 16:35:24 +0000 (11:35 -0500)
committerDan Winship <danw@gnome.org>
Sat, 17 Nov 2012 16:37:23 +0000 (11:37 -0500)
per recommendation of the httpbis spec

libsoup/soup-message-client-io.c

index 7c62368..06fe5cc 100644 (file)
@@ -97,20 +97,17 @@ get_request_headers (SoupMessage *req, GString *header,
                }
        }
 
-       if (priv->http_version == SOUP_HTTP_1_0) {
-               g_string_append_printf (header, "%s %s HTTP/1.0\r\n",
-                                       req->method, uri_string);
-       } else {
-               g_string_append_printf (header, "%s %s HTTP/1.1\r\n",
-                                       req->method, uri_string);
-               if (!soup_message_headers_get_one (req->request_headers, "Host")) {
-                       if (soup_uri_uses_default_port (uri)) {
-                               g_string_append_printf (header, "Host: %s\r\n",
-                                                       uri_host);
-                       } else {
-                               g_string_append_printf (header, "Host: %s:%d\r\n",
-                                                       uri_host, uri->port);
-                       }
+       g_string_append_printf (header, "%s %s HTTP/1.%d\r\n",
+                               req->method, uri_string,
+                               (priv->http_version == SOUP_HTTP_1_0) ? 0 : 1);
+
+       if (!soup_message_headers_get_one (req->request_headers, "Host")) {
+               if (soup_uri_uses_default_port (uri)) {
+                       g_string_append_printf (header, "Host: %s\r\n",
+                                               uri_host);
+               } else {
+                       g_string_append_printf (header, "Host: %s:%d\r\n",
+                                               uri_host, uri->port);
                }
        }
        g_free (uri_string);