-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/httputil: ReverseProxy does not flush header writes #31126
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
Labels
Comments
just opened #31125 for the same issue :) |
Change https://golang.org/cl/170066 mentions this issue: |
Seriously? 22 minutes apart? What are the odds? |
Closing here as a dup of #31125 then. Feel free to post your analysis on that issue, if you believe it could be helpful. |
gopherbot
pushed a commit
that referenced
this issue
Mar 29, 2019
A regression was introduced in CL 137335 (5440bfc) that caused FlushInterval to not be honored until the first Write() call was encountered. This change starts the flush timer as part of setting up the maxLatencyWriter. Fixes #31125 Fixes #31126 Change-Id: I75325bd926652922219bd1457b2b00ac6d0d41b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/170066 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?go version go1.12.1 linux/amd64
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 have a server with a long-poll endpoint which returns response headers immediately, then delays writing anything in the response body until an event occurs. Events typically occur after a long delay.
The client waits for the response headers with a very short timeout (and throws an error if the headers aren't received), then waits for a response body with a very long timeout.
I'm trying to use httputil.ReverseProxy to write a proxy that sits between this client and server. However, the client almost always errors out because it didn't receive response headers within its timeout.
The problem is that httputil.ReverseProxy only flushes response body writes to the client. It does not flush header writes, regardless of the FlushInterval.
More specifically, ReverseProxy calls
rw.WriteHeader(res.StatusCode)
then waits for a read on the response body. Neither WriteHeader() nor ReverseProxy flushesrw
before ReverseProxy begins waiting for a body read.Example code: https://play.golang.org/p/SRbVbyZYsnp
What did you expect to see?
2009/11/10 23:00:00 Server wrote status
2009/11/10 23:00:00 Client got status
2009/11/10 23:00:05 Server wrote body
2009/11/10 23:00:10 Server done writing
What did you see instead?
2009/11/10 23:00:00 Server wrote status
2009/11/10 23:00:05 Server wrote body
2009/11/10 23:00:05 Client got status
2009/11/10 23:00:10 Server done writing
The text was updated successfully, but these errors were encountered: