Skip to content
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

net/http/httputil: ReverseProxy flush immediately additional case #41642

Closed
jsign opened this issue Sep 26, 2020 · 9 comments
Closed

net/http/httputil: ReverseProxy flush immediately additional case #41642

jsign opened this issue Sep 26, 2020 · 9 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jsign
Copy link
Contributor

jsign commented Sep 26, 2020

While using ReverseProxy in a stream-based HTTP API I got hit by the default value of FlushInterval. This API used a Transfer-Encoding: chunked and Content-Length: -1 for the intention of a stream-based response.

The default value of FlushInterval isn't latency based nor flush immediately which seems fine in general, but in this particular case, the end client (talking with the reverse-proxy) wasn't seeing any stream messages since they were being buffered until the HTTP response finished, which in this case was never since only gets canceled by the client.

Looking at ReverseProxy implementation the solution was simple, just use FlushInterval = -1 to signal to flush immediately. Interestingly, the exact same situation was in a TODO comment which from my point of view sounds like it might be a good idea to implement.

I'm opening the discussion to see if makes sense. If that's the case, I can propose a PR if we decide is a good idea to also flush immediately on Content-Length: -1 or other decided case in addition to the current exception Content-Type: "text/event-stream".

@aofei
Copy link
Contributor

aofei commented Sep 27, 2020

FYI, Caddy's approach.

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 29, 2020
@andybons andybons added this to the Unplanned milestone Sep 29, 2020
@andybons
Copy link
Member

@bradfitz

@bradfitz
Copy link
Contributor

bradfitz commented Oct 6, 2020

Doing that TODO from line 409 seems reasonable.

/cc @neild

@jsign
Copy link
Contributor Author

jsign commented Oct 6, 2020

Sounds good, I can take care of this. I'll make a PR in the next days.

@gopherbot
Copy link

Change https://golang.org/cl/260637 mentions this issue: net/http/httputil: make ReverseProxy flush immediately if Content-Length is -1

@networkimprov
Copy link

cc @odeke-em as possible reviewer.

@odeke-em
Copy link
Member

odeke-em commented Oct 8, 2020

Thank you for the tag @networkimprov :) I've provided my review.

@odeke-em odeke-em modified the milestones: Unplanned, Go1.16 Oct 12, 2020
@odeke-em
Copy link
Member

@dmitshur should we perhaps backport this change?

@dmitshur
Copy link
Contributor

This was a TODO comment added 2 years ago that was only reported 2 weeks ago. That suggests to me it's not a very serious issue, and fine to leave for 1.16.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 12, 2020
@golang golang locked and limited conversation to collaborators Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants