From ce85149629f560615d54b00c935b7b842e8de7da Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 7 Dec 2018 18:06:59 +0100 Subject: [PATCH] BUG/MINOR: mux-h1: Remove the connection header when it is useless 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mux_h1.c b/src/mux_h1.c index 58e0879470..90e6ff9fe5 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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); + } } }