MEDIUM: h1: Accept invalid T-E values with accept-invalid-http-response option
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 11 Sep 2024 13:02:07 +0000 (15:02 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Sep 2024 07:26:33 +0000 (09:26 +0200)
commitba9d151c463dab36aedee05bf8f2469886dafe69
treea58b84696d8f5873755ccb088b298e86e0e4eeaf
parent6cae9b3ead0af8c751e9ed1e160432ae4a8773c6
MEDIUM: h1: Accept invalid T-E values with accept-invalid-http-response option

Since the 2.6, A parsing error is reported when the chunked encoding is
found twice. As stated in RFC9112, A sender must not apply the chunked
transfer coding more than once to a message body. It means only one chunked
coding must be found. In addition, empty values are also rejected becaues it
is forbidden by RFC9110.

However, in both cases, it may be useful to relax the rules for trusted
legacy servers when accept-invalid-http-response option is set. Especially
because it was accepted on 2.4 and older. In addition, T-E header is now
sanitized before sending it. It is not a problem Because it is a hop-by-hop
header

Note that it remains invalid on client side because there is no good reason
to relax the parsing on this side. We can argue a server is trusted so we
can decide to support some legacy behavior. It is not true on client side
and it is highly suspicious if a client is sending an invalid T-E header.

Note also we continue to reject unsupported T-E values (so all codings except
"chunked"). Because the "TE" header is sanitized and cannot contain other value
than "Trailers", there is absolutely no reason for a server to use something
else.

This patch should fix the issue #2677. It could probably be backported as
far as 2.6 if necessary.

(cherry picked from commit 1900ca475fa005b8000c4652457fedf282fa864d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/h1.c
src/mux_h1.c