diff --git a/src/h1_htx.c b/src/h1_htx.c index 70e4b2cb0..6ea19d265 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -178,7 +178,18 @@ static int h1_postparse_req_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx h1m->curr_len = h1m->body_len = 0; } + flags = h1m_htx_sl_flags(h1m); + if ((flags & (HTX_SL_F_CONN_UPG|HTX_SL_F_BODYLESS)) == HTX_SL_F_CONN_UPG) { + int i; + + for (i = 0; hdrs[i].n.len; i++) { + if (isteqi(hdrs[i].n, ist("upgrade"))) + hdrs[i].v = IST_NULL; + } + h1m->flags &=~ H1_MF_CONN_UPG; + flags &= ~HTX_SL_F_CONN_UPG; + } sl = htx_add_stline(htx, HTX_BLK_REQ_SL, flags, meth, uri, vsn); if (!sl || !htx_add_all_headers(htx, hdrs)) goto error; diff --git a/src/mux_h2.c b/src/mux_h2.c index 5fd492a11..45506c65d 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -5288,7 +5288,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx) continue; /* Convert connection: upgrade to Extended connect from rfc 8441 */ - if (isteqi(list[hdr].n, ist("connection"))) { + if ((sl->flags & HTX_SL_F_CONN_UPG) && isteqi(list[hdr].n, ist("connection"))) { /* rfc 7230 #6.1 Connection = list of tokens */ struct ist connection_ist = list[hdr].v; do { @@ -5306,7 +5306,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx) } while (istlen(connection_ist)); } - if (isteq(list[hdr].n, ist("upgrade"))) { + if ((sl->flags & HTX_SL_F_CONN_UPG) && isteq(list[hdr].n, ist("upgrade"))) { /* rfc 7230 #6.7 Upgrade = list of protocols * rfc 8441 #4 Extended connect = :protocol is single-valued *