BUG/MINOR: mux-h1: Skip trailers for non-chunked outgoing messages

Unlike H1, H2 messages may contains trailers while the header "Content-Length"
is set. Indeed, because of the framed structure of HTTP/2, it is no longer
necessary to use the chunked transfer encoding. So Trailing HEADERS frames,
after all DATA frames, may be added on messages with an explicit content length.

But in H1, it is impossible to have trailers on non-chunked messages. So when
outgoing messages are formatted by the H1 multiplexer, if the message is not
chunked, all trailers must be dropped.

This patch must be backported to 2.0 and 1.9. However, the patch will have to be
adapted for the 1.9.
This commit is contained in:
Christopher Faulet 2019-06-27 17:40:14 +02:00
parent 2df8cad0fe
commit 5433a0b021

View File

@ -1696,7 +1696,9 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
goto done;
}
else if (type == HTX_BLK_EOT || type == HTX_BLK_TLR) {
if (!chunk_memcat(&tmp, "0\r\n", 3))
/* If the message is not chunked, never
* add the last chunk. */
if ((h1m->flags & H1_MF_CHNK) && !chunk_memcat(&tmp, "0\r\n", 3))
goto copy;
goto trailers;
}
@ -1715,6 +1717,11 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
goto error;
trailers:
h1m->state = H1_MSG_TRAILERS;
/* If the message is not chunked, ignore
* trailers. It may happen with H2 messages. */
if (!(h1m->flags & H1_MF_CHNK))
break;
if (type == HTX_BLK_EOT) {
if (!chunk_memcat(&tmp, "\r\n", 2))
goto copy;