[libsoup/libsoup-3-0] http2: remove Host and Connection headers from request after a redirect from HTTP/1 to HTTP/2



commit 8c34ee4adcbd1db170befe8980b32f87b71d2eda
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Tue Jun 7 10:55:22 2022 +0200

    http2: remove Host and Connection headers from request after a redirect from HTTP/1 to HTTP/2
    
    Otherwise we get a protocol error since Host header is replaced by :authority pseudo-header field in 
HTTP/2.
    
    Fixes #278

 libsoup/soup-message.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index e7d9b3ab..8bf392c0 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -3131,8 +3131,10 @@ soup_message_update_request_host_if_needed (SoupMessage *msg)
 {
         SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
 
-        if (priv->http_version == SOUP_HTTP_2_0)
+        if (priv->http_version == SOUP_HTTP_2_0) {
+                soup_message_headers_remove_common (priv->request_headers, SOUP_HEADER_HOST);
                 return;
+        }
 
         if (soup_message_headers_get_one_common (priv->request_headers, SOUP_HEADER_HOST))
                 return;
@@ -3145,8 +3147,10 @@ soup_message_force_keep_alive_if_needed (SoupMessage *msg)
 {
         SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
 
-        if (priv->http_version == SOUP_HTTP_2_0)
+        if (priv->http_version == SOUP_HTTP_2_0) {
+                soup_message_headers_remove_common (priv->request_headers, SOUP_HEADER_CONNECTION);
                 return;
+        }
 
         /* Force keep alive connections for HTTP 1.0. Performance will
          * improve when issuing multiple requests to the same host in


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