]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Remove the connection header when it is useless
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 7 Dec 2018 17:06:59 +0000 (18:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 8 Dec 2018 14:44:58 +0000 (15:44 +0100)
When the connection mode can be deduced from the HTTP version, we remove the
redundant connection header. So "keep-alive" connection header is removed from
HTTP/1.1 messages and "close" connection header is remove from HTTP/1.0
messages.

src/mux_h1.c

index 58e0879470c835a7e75c59e477f89744942cbc1d..90e6ff9fe563e2974be766d432e3facacc8c1bb7 100644 (file)
@@ -689,6 +689,12 @@ static void h1_update_req_conn_hdr(struct h1s *h1s, struct h1m *h1m,
                        if (htx)
                                h1_add_conn_hdr(h1m, htx, ist("keep-alive"));
                }
+               if ((h1m->flags & (H1_MF_VER_11|H1_MF_CONN_KAL)) == (H1_MF_VER_11|H1_MF_CONN_KAL)) {
+                       if (conn_val)
+                               *conn_val = ist("");
+                       if (htx)
+                               h1_remove_conn_hdrs(h1m, htx);
+               }
        }
        else { /* H1S_F_WANT_CLO && !PR_O2_FAKE_KA */
                if (h1m->flags & H1_MF_CONN_KAL) {
@@ -703,6 +709,12 @@ static void h1_update_req_conn_hdr(struct h1s *h1s, struct h1m *h1m,
                        if (htx)
                                h1_add_conn_hdr(h1m, htx, ist("close"));
                }
+               if ((h1m->flags & (H1_MF_VER_11|H1_MF_CONN_CLO)) == H1_MF_CONN_CLO) {
+                       if (conn_val)
+                               *conn_val = ist("");
+                       if (htx)
+                               h1_remove_conn_hdrs(h1m, htx);
+               }
        }
 }
 
@@ -728,6 +740,12 @@ static void h1_update_res_conn_hdr(struct h1s *h1s, struct h1m *h1m,
                        if (htx)
                                h1_add_conn_hdr(h1m, htx, ist("keep-alive"));
                }
+               if ((h1m->flags & (H1_MF_VER_11|H1_MF_CONN_KAL)) == (H1_MF_VER_11|H1_MF_CONN_KAL)) {
+                       if (conn_val)
+                               *conn_val = ist("");
+                       if (htx)
+                               h1_remove_conn_hdrs(h1m, htx);
+               }
        }
        else { /* H1S_F_WANT_CLO */
                if (h1m->flags & H1_MF_CONN_KAL) {
@@ -742,6 +760,12 @@ static void h1_update_res_conn_hdr(struct h1s *h1s, struct h1m *h1m,
                        if (htx)
                                h1_add_conn_hdr(h1m, htx, ist("close"));
                }
+               if ((h1m->flags & (H1_MF_VER_11|H1_MF_CONN_CLO)) == H1_MF_CONN_CLO) {
+                       if (conn_val)
+                               *conn_val = ist("");
+                       if (htx)
+                               h1_remove_conn_hdrs(h1m, htx);
+               }
        }
 }