]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2/htx: Set the flag HTX_SL_F_BODYLESS for messages without body
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 Feb 2019 09:12:56 +0000 (10:12 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 18 Feb 2019 15:25:06 +0000 (16:25 +0100)
This information is usefull to know if a body is expected or not, regardless the
presence or not of the header "Content-Length" and its value. Once the ES flag
is set on the header frame or when the content length is 0, we can safely add
the flag HTX_SL_F_BODYLESS on the HTX start-line.

Among other things, it will help the mux-h1 to know if it should add TE header
or not. It will also help the HTTP compression filter.

This patch must be backported to 1.9 because a bug fix depends on it.

src/h2.c

index 6a1debf957ea1349c196a44cf4414d3988a6c2ca..d7031c75d91c5be9b89a9be741588c8bd1f9a82d 100644 (file)
--- a/src/h2.c
+++ b/src/h2.c
@@ -684,6 +684,9 @@ int h2_make_htx_request(struct http_hdr *list, struct htx *htx, unsigned int *ms
                        goto fail;
        }
 
+       if (!(*msgf & H2_MSGF_BODY) || ((*msgf & H2_MSGF_BODY_CL) && *body_len == 0))
+               sl_flags |= HTX_SL_F_BODYLESS;
+
        /* update the start line with last detected header info */
        sl->flags |= sl_flags;
 
@@ -890,6 +893,9 @@ int h2_make_htx_response(struct http_hdr *list, struct htx *htx, unsigned int *m
                        goto fail;
        }
 
+       if (!(*msgf & H2_MSGF_BODY) || ((*msgf & H2_MSGF_BODY_CL) && *body_len == 0))
+               sl_flags |= HTX_SL_F_BODYLESS;
+
        /* update the start line with last detected header info */
        sl->flags |= sl_flags;