BUG/MINOR: h1: Replace authority validation to conform RFC3986
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 22 Nov 2022 09:04:16 +0000 (10:04 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 22 Nov 2022 16:49:10 +0000 (17:49 +0100)
commite16ffb038382fa63580fd404a108ec4447d60e37
tree409723e5ddb9de6972b2966324b1248b18123cca
parente5dfe1169d50acd3a4c7d04441203718f1964836
BUG/MINOR: h1: Replace authority validation to conform RFC3986

Except for CONNECT method, where a normalization is performed, we expected
to have an exact match between the authority and the host header value.
However it was too strict. Indeed, default port must be handled and the
matching must respect the RFC3986.

There is already a scheme based normalizeation performed on the URI later,
on the HTX message. And we cannot normalize the URI during H1 parsing to be
able to report proper errors on the original raw buffer. And a systematic
read-only normalization to validate the authority will consume CPU for only
few requests. At the end, we decided to perform extra-checks when the exact
match fails. Now, following authority/host are considered as equivalent:

  http:  domain.com <=> domain.com:80  <=> domain.com:
  https: domain.com <=> domain.com:443 <=> domain.com:

This patch depends on:

  * MINOR: h1: Consider empty port as invalid in authority for CONNECT
  * MINOR: http: Considere empty ports as valid default ports

It is a bug regarding the RFC3986. Technically, I may be backported as far
as 2.4. However, this must be discussed first. If it is backported, the
commits above must be backported too.
src/h1.c