diff --git a/src/mux_h1.c b/src/mux_h1.c index 92eea1867..1e4041bd7 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1518,6 +1518,8 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun if (!htx_reqline_to_h1(sl, tmp)) goto copy; h1m->flags |= H1_MF_XFER_LEN; + if (sl->flags & HTX_SL_F_BODYLESS) + h1m->flags |= H1_MF_CLEN; h1m->state = H1_MSG_HDR_FIRST; break; @@ -1582,10 +1584,12 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun } } - if (h1s->status >= 200 && h1s->status != 204 && h1s->status != 304 && - h1s->meth != HTTP_METH_HEAD && !(h1s->meth == HTTP_METH_CONNECT && h1s->status == 200) && - (h1m->flags & (H1_MF_VER_11|H1_MF_RESP|H1_MF_CLEN|H1_MF_CHNK|H1_MF_XFER_LEN)) == - (H1_MF_VER_11|H1_MF_RESP|H1_MF_XFER_LEN)) { + if (((h1m->flags & (H1_MF_VER_11|H1_MF_RESP|H1_MF_CLEN|H1_MF_CHNK|H1_MF_XFER_LEN)) == + (H1_MF_VER_11|H1_MF_XFER_LEN)) || + (h1s->status >= 200 && h1s->status != 204 && h1s->status != 304 && + h1s->meth != HTTP_METH_HEAD && !(h1s->meth == HTTP_METH_CONNECT && h1s->status == 200) && + (h1m->flags & (H1_MF_VER_11|H1_MF_RESP|H1_MF_CLEN|H1_MF_CHNK|H1_MF_XFER_LEN)) == + (H1_MF_VER_11|H1_MF_RESP|H1_MF_XFER_LEN))) { /* chunking needed but header not seen */ if (!chunk_memcat(tmp, "transfer-encoding: chunked\r\n", 28)) goto copy;