BUG/MINOR: mux-h1: verify the request's version before dropping connection: keep-alive

The mux h1 properly avoid to set "connection: keep-alive" when the response
is in HTTP/1.1 but it forgot to check the request's version. Thus when the
client requests using HTTP/1.0 and connection: keep-alive (like ab does),
the response is in 1.1 with no keep-alive and ab waits for the close without
checking for the content-length. Response headers actually depend on the
recipient, thus on both request and response's version.

This patch must be backported to 1.9.
This commit is contained in:
Willy Tarreau 2019-02-08 15:35:38 +01:00
parent f959d0809e
commit 7701cad444

View File

@ -784,13 +784,15 @@ static void h1_update_res_conn_hdr(struct h1s *h1s, struct h1m *h1m,
if (htx)
h1_remove_conn_hdrs(h1m, htx);
}
if (!(h1m->flags & (H1_MF_VER_11|H1_MF_CONN_KAL))) {
if (!(h1m->flags & H1_MF_CONN_KAL) &&
!((h1m->flags & h1s->req.flags) & H1_MF_VER_11)) {
if (conn_val)
*conn_val = ist("keep-alive");
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)) {
else if ((h1m->flags & H1_MF_CONN_KAL) &&
((h1m->flags & h1s->req.flags) & H1_MF_VER_11)) {
if (conn_val)
*conn_val = ist("");
if (htx)