Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: with Transfer-Encoding: chunked, Transport doesn't reuse the tcp connection #15703
changed the title
with Transfer-Encoding: chunked, http client doesn't reuse the tcp connection
May 16, 2016
Actually, I had misread your repro code the first time. This is working as intended.
The lack of connection of reuse (that I see 40-60% of the time with your repo) isn't due to chunked encoding, but because the handler hasn't yet finished when you call
If you put a
And if you move the
The race you're seeing is because depending on goroutine scheduling.
You have two goroutines, S(erver) and C(lient):
You're seeing them sometimes scheduled like this:
That is a valid result.
I recommend you remove the flush.
I've added a new test in https://golang.org/cl/23200 to guarantee the existing behavior when the flush is in the right spot.
Please let me know if I misunderstand something.