-
Notifications
You must be signed in to change notification settings - Fork 264
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
fix: restore req body #397
Conversation
Your Render PR Server URL is https://chproxy-pr-397.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-cmv26nv109ks739iu2t0. |
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.
Is there an easy way to add a test in order to assess the before/after change behavior (to ensure we don't have a regression in the future)?
proxy.go
Outdated
// update body | ||
rp(rw, req) | ||
|
||
// Restore req.Body after it's consumed by 'rp' for potential reuse. | ||
req.Body = io.NopCloser(bytes.NewBuffer(body)) | ||
req.Body.Close() |
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.
why do you have a call to Close() here and there? https://github.com/ContentSquare/chproxy/pull/397/files#diff-8b7f25bac2ae04c2ce2abb628c6aa28103fd113103a62f3e9d232fa995684915R111
I don't know what should be done, but it doesn't look logic to have inconsistencies for the same use case.
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.
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.
You are right. This one was at the beginning. I'll check if can be removed
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.
req.Body.Close() appears in few places. Maybe, better to refactor it in a separate PR?
I'll try |
03bae19
to
1698f40
Compare
proxy_test.go
Outdated
} | ||
|
||
//func TestRequestBody(t *testing.T) { |
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.
Can you remove the commented code?
d5d10c2
to
245d3ea
Compare
245d3ea
to
11de1a4
Compare
Description
Fix restore original req.Body
Pull request type
implements #336
Please check the type of change your PR introduces:
Checklist
Does this introduce a breaking change?
Further comments