]> Cypherpunks.ru repositories - gostls13.git/commit
net/http: conservatively flush Transport request headers by default
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 23 May 2018 22:30:41 +0000 (22:30 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 24 May 2018 19:16:58 +0000 (19:16 +0000)
commit8e5cb0da1b7c6d7c18a60ff0c688538dbe27f8f3
treefb19b2ec6d912caf7ea226bd5fa4b059047aa9ae
parentb0b0921220b2584eec8ee31b40b213d9f9322fce
net/http: conservatively flush Transport request headers by default

This changes the http.Transport to flush the bufio.Writer between
writing the request headers and the body.

That wasn't done in the past to minimize the number of TCP packets on
the wire, but that's just an optimization, and it causes problems when
servers are waiting for the headers and the client is blocked on
something before reading the body.

Instead, only do the don't-flush optimization if we know we're not
going to block, whitelisting a set of common in-memory Request.Body
types. (the same set of types special-cased by http.NewRequest)

Fixes #22088

Change-Id: I7717750aa6df32dd3eb92d181b45bc7af24b1144
Reviewed-on: https://go-review.googlesource.com/114316
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
src/net/http/transfer.go
src/net/http/transfer_test.go
src/net/http/transport_test.go