Le 27/03/2019 à 07:59, Marco Corte a écrit :
Good morning!

Christopher helped me fixing the http-use-htx issue "BUG/MEDIUM:
proto_htx: Fix data size update if end of the cookie is removed".

I am testing haproxy 1.9.5 with the same site real server, with the same
configuration:

    browser <--- HTTP/2 --->  haproxy  <--- HTTP --->  real server

Things are working better, but I found a different problem: the user
session works properly for many pages, then a POST fails with a 411
error.

The behaviour is triggered by http-use-htx.

I am not able to find exactly where the problem is, but I have the
"haproxy -d"
output of a user session, which cannot be anonymized without loosing
important informations.

If anyone is interested, I can send it privately.

Thank you a lot

.marcoc


Marco,

After checking the haproxy output that you sent me, the error happens because the content-length header is skipped when the request is sent to the server. It is skipped because the POST is empty, so it is set to 0. Your server seems to reject empty POST request when there is no content-length header. It is not strictly mandatory to have this header in such case but there is no reason to skip it.
--
Christopher Faulet
>From 07e02acaaeb104c9608cb93e1d988bae75ae16be Mon Sep 17 00:00:00 2001
From: Christopher Faulet <[email protected]>
Date: Wed, 27 Mar 2019 15:44:56 +0100
Subject: [PATCH] BUG/MINOR: mux-h1: Only skip invalid C-L headers on output

When an HTTP request with an empty body is received, the flag HTX_SL_F_BODYLESS
is set on the HTX start-line block. It is true if the header content-length is
explicitly set to 0 or if it is omitted for a non chunked request.

On the server side, when the request is reformatted, because HTX_SL_F_BODYLESS
is set, the flag H1_MF_CLEN is added on the request parser. It is done to not
add an header transfer-encoding on bodyless requests. But if an header
content-length is explicitly set to 0, when it is parsed, because H1_MF_CLEN is
set, the function h1_parse_cont_len_header() returns 0, meaning the header can
be dropped. So in such case, a request without any header content-length is sent
to the server.

Some servers seems to reject empty POST requests with an error 411 when there is
no header content-length. So to fix this issue, on the output side, only headers
with an invalid content length are skipped, ie only when the function
h1_parse_cont_len_header() returns a negative value.

This patch must be backported to 1.9.
---
 src/mux_h1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mux_h1.c b/src/mux_h1.c
index 65e99153d..2b4e1cf09 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -1557,7 +1557,8 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
 				if (isteqi(n, ist("transfer-encoding")))
 					h1_parse_xfer_enc_header(h1m, v);
 				else if (isteqi(n, ist("content-length"))) {
-					if (h1_parse_cont_len_header(h1m, &v) <= 0)
+					/* Only skip C-L header with invalid value. */
+					if (h1_parse_cont_len_header(h1m, &v) < 0)
 						goto skip_hdr;
 				}
 				else if (isteqi(n, ist("connection"))) {
-- 
2.20.1

Reply via email to