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.
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 58e0879..90e6ff9 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -689,6 +689,12 @@
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 @@
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 @@
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 @@
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);
+ }
}
}