mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
BUG/MEDIUM: mux-h1: Remove "Upgrade:" header for requests with payload
Instead of returning a 501-Not-implemented error when "Ugrade:" header is found for a request with a payload, the header is removed. This way, the upgrade is disabled and the request is still sent to the server. It is required because some frameworks seem to try to perform H2 upgrade on every requests, including POST ones. The h2 mux was slightly fixed to convert Upgrade requests to extended connect ones only if the rigth HTX flag is set. This patch should fix the issue #1381. It must be backported to 2.4.
This commit is contained in:
parent
f14edc8212
commit
52a5ec2d18
11
src/h1_htx.c
11
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;
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user