]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.20] net/http: permit requests with invalid Host headers
authorDamien Neil <dneil@google.com>
Wed, 19 Jul 2023 17:30:46 +0000 (10:30 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 14 Aug 2023 21:56:57 +0000 (21:56 +0000)
commitede3e278ae8df8ce1beec4b251dbaa68b8d2ad48
treed966513bb7dd7059b9c06501ae2aeab99d3de1ac
parent201f8b40dceb7a821fd9958b2061c33d436d107b
[release-branch.go1.20] net/http: permit requests with invalid Host headers

Historically, the Transport has silently truncated invalid
Host headers at the first '/' or ' ' character. CL 506996 changed
this behavior to reject invalid Host headers entirely.
Unfortunately, Docker appears to rely on the previous behavior.

When sending a HTTP/1 request with an invalid Host, send an empty
Host header. This is safer than truncation: If you care about the
Host, then you should get the one you set; if you don't care,
then an empty Host should be fine.

Continue to fully validate Host headers sent to a proxy,
since proxies generally can't productively forward requests
without a Host.

For #60374
Fixes #61431
Fixes #61826

Change-Id: If170c7dd860aa20eb58fe32990fc93af832742b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/511155
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
(cherry picked from commit b9153f6ef338baee5fe02a867c8fbc83a8b29dd1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/518756
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
src/net/http/request.go
src/net/http/request_test.go