|
|
- commit 52131680c42ddbfa6f2b5d109ffc79c28f44e42a
- Author: Christopher Faulet <cfaulet@haproxy.com>
- Date: Thu Jun 27 17:40:14 2019 +0200
-
- 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.
-
- (cherry picked from commit 5433a0b0215c791b4165bddd360a254fa141c6e9)
- Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
-
- diff --git a/src/mux_h1.c b/src/mux_h1.c
- index e497e6f6..e7d769b4 100644
- --- a/src/mux_h1.c
- +++ b/src/mux_h1.c
- @@ -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;
|