diff --git a/src/h1_htx.c b/src/h1_htx.c index e731e8826..5845694ae 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -301,6 +302,11 @@ static int h1_postparse_res_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx h1m->flags &= ~(H1_MF_CONN_UPG|H1_MF_UPG_WEBSOCKET); if (((h1m->flags & H1_MF_METH_CONNECT) && code >= 200 && code < 300) || code == 101) { + if (h1m->flags & H1_MF_XFER_ENC) + http_del_hdr(hdrs, ist("transfer-encoding")); + if (h1m->flags & H1_MF_CLEN) + http_del_hdr(hdrs, ist("content-length")); + h1m->flags &= ~(H1_MF_CLEN|H1_MF_CHNK); h1m->flags |= H1_MF_XFER_LEN; h1m->curr_len = h1m->body_len = 0; @@ -310,6 +316,15 @@ static int h1_postparse_res_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx else if ((h1m->flags & H1_MF_METH_HEAD) || (code >= 100 && code < 200) || (code == 204) || (code == 304)) { /* Responses known to have no body. */ + if ((code >= 100 && code < 200) || (code == 204)) { + if (h1m->flags & H1_MF_XFER_ENC) + http_del_hdr(hdrs, ist("transfer-encoding")); + if (h1m->flags & H1_MF_CLEN) + http_del_hdr(hdrs, ist("content-length")); + + h1m->flags &= ~(H1_MF_CLEN|H1_MF_CHNK); + } + h1m->flags |= H1_MF_XFER_LEN; h1m->curr_len = h1m->body_len = 0; if (code >= 200)