net/http: Client hangs forever on 101 Status Code #44988
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran the following script locally, it takes forever, do not run that script on the playground because it may be killed by the sandbox as it takes forever.
https://play.golang.org/p/oUNf5aEleAr
What did you expect to see?
Timeout arguments to be enforced.
What did you see instead?
It takes forever.
IMPORTANT
About my title, well... I am not sure, somebody(Jorik) on gophers.slack.com noticed that the server was replying with a 101 status code on Firefox, not sure if that's the reason, in Chrome we don't get such 101 HTTP status, it just hangs. I don't know if httpClient gets such 101 status, all I know is it hangs, so if the reason is 101 Status code, then the title is appropriate, otherwise the title is misleading.
Update
A user(Nils Preuschoff) in that slack channel pointed me at a modified snippet:
https://play.golang.org/p/FPb2i0h--z6
It proves that indeed the faulty behaviour happens on Status Code 101, showing the HTTP status code 101 is the last event prior to hanging on ioutil.ReadAll(), is this a bug on Go? I am setting the timeout on both, header and response body, it should be honored, right?
Update2
Here I attach the equivalent fasthttp snippet doing a request to the same host, I used the default timeout settings from fasthttp to keep it simple, fasthttp, same as http package, has defaults timeouts values greater than 0 (no timeout), fasthttp returns immediately, while the http package hangs forever ...
https://play.golang.org/p/lq8FkgP7oJp
The text was updated successfully, but these errors were encountered: