Skip to content

net/http/httputil: ReverseProxy uses CloseNotifier before body consumption #13666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
orivej opened this issue Dec 18, 2015 · 7 comments
Closed
Milestone

Comments

@orivej
Copy link

orivej commented Dec 18, 2015

Since 99fb191, one of Consul tests does not pass because CloseNotify for clientGone gets triggered in httputil.ReverseProxy.ServeHTTP when the client in fact is not gone.

How to reproduce:

go get -u -v github.com/hashicorp/consul
go test github.com/hashicorp/consul/api -run TestLock_MonitorRetry

The test should not fail, but does since aforementioned commit. If I comment out requestCanceler.CancelRequest(outreq) in net/http/httputil/reverseproxy.go, it passes again.

Downstream issue: hashicorp/consul#1524

@bradfitz
Copy link
Contributor

Are you using HTTP/1.1 pipelining?

@bradfitz
Copy link
Contributor

Nevermind, I see now that httputil.ReverseProxy doesn't obey the new tightened rules for CloseNotifier.

I can fix.

@bradfitz bradfitz self-assigned this Dec 18, 2015
@bradfitz bradfitz added this to the Go1.6 milestone Dec 18, 2015
@bradfitz bradfitz changed the title Premature CloseNotify in httputil.ReverseProxy.ServeHTTP net/http/httputil: ReverseProxy uses CloseNotifier before body consumption Dec 18, 2015
@pwaller
Copy link
Contributor

pwaller commented Dec 23, 2015

@bradfitz I can't see mention of the tightened rules in the release notes or on the mailing list. I guess you're referring to this CL and this new rule?:

CloseNotify is undefined before Request.Body has been fully read.

For me, I get the RequestProxy giving http: proxy error: net/http: request canceled whenever there is a HTTP post; which I assume is this issue.

I guess the fix is straightforward and the call to CloseNotify() just needs hoisting inside RunOnFirstRead?

@starchou
Copy link

@pwaller I have the same issue . and I use POST,PUT,DELETE method ,they all output error :http: proxy error: net/http: request canceled .
@bradfitz can you fix it ?
3q

@starchou
Copy link

@pwaller I copy it and move code like that: https://gist.github.com/starchou/3fa257ea20fdf6babeab
it's work now.

@orivej
Copy link
Author

orivej commented Dec 25, 2015

This was discussed a little on the list: http://thread.gmane.org/gmane.comp.lang.go.general/170241

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/18144 mentions this issue.

@golang golang locked and limited conversation to collaborators Jan 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants