]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.21] 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:55:15 +0000 (21:55 +0000)
commit179821c9e12d18c8134429fabe50d3dfaecb948e
tree0c2543d53718b21d5de33e63ed862592e0917a58
parent93989514795d8145344262124dde8bce089ff33e
[release-branch.go1.21] 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 #61904

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/+/518856
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/net/http/request.go
src/net/http/request_test.go