-
Notifications
You must be signed in to change notification settings - Fork 352
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
proxy: fix proxy panic caused by broken backend #2984
Conversation
96f4184
to
aaffc22
Compare
@@ -192,9 +192,9 @@ func (c *context) shunted() bool { | |||
return c.servedWithResponse | |||
} | |||
|
|||
func (c *context) setResponse(r *http.Response, preserveOriginal bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to cleanup this although its unrelated
defer func() { | ||
if ctx.response != nil && ctx.response.Body != nil { | ||
err := ctx.response.Body.Close() | ||
if err != nil { | ||
ctx.Logger().Errorf("error during closing the response body: %v", err) | ||
} | ||
} | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided not to pile-up defers but to use straightforward cleanup sequence after streaming the response.
Would like to refactor other defers as well separately.
// based on the augmented incoming request | ||
func (p *Proxy) mapRequest(ctx *context, requestContext stdlibcontext.Context) (*http.Request, routing.Metrics, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to createOutgoingRequest
?
65b2792
to
13dac9e
Compare
Broken backend that closes connection before sending response body may trigger proxy panic if client sends `Expect: 100-continue` header, see golang/go#53808 Signed-off-by: Alexander Yastrebov <[email protected]>
Close outgoing request body to fix proxy panic. Signed-off-by: Alexander Yastrebov <[email protected]>
13dac9e
to
e22888a
Compare
The plan is to fix the stdlib, see golang/go#66594 |
Broken backend that closes connection before sending response body may trigger proxy panic if client sends
Expect: 100-continue
header, see golang/go#53808Close outgoing request body to fix proxy panic.