]> Cypherpunks.ru repositories - gostls13.git/commit
net/http: fix hang in probing for a zero-length request body
authorDamien Neil <dneil@google.com>
Fri, 6 Aug 2021 02:26:21 +0000 (19:26 -0700)
committerDamien Neil <dneil@google.com>
Thu, 2 Sep 2021 17:00:30 +0000 (17:00 +0000)
commitacc2957bc9873ab7e65942045830a3dc0592eda2
tree59e58c2ac80f487b9ef4cca1d622d7a2649bbe2e
parent2a463a22cee8ddbd4801acd2ef34eefa551a718a
net/http: fix hang in probing for a zero-length request body

Fix a hang that occurs when making a request and all of the following apply:
* The request method is one of GET, HEAD, DELETE, OPTIONS, PROPFIND, or SEARCH.
* The Request.Body is non-nil.
* The content length is not set, or is set to -1.
* Transfer-Encoding: chunked is not set.
* The request body does not respond to a read within 200ms.

In this case, we give up on probing for a zero-length body and send the
request while the probe completes in the background. Fix a bug in the
io.Reader wrapping the in-flight probe: It should return io.EOF after
the probe completes, but does not.

Fixes #47568.

Change-Id: I7f9188c96e1210055df68424081af927006e4816
Reviewed-on: https://go-review.googlesource.com/c/go/+/340256
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/client_test.go
src/net/http/transfer.go