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

Save the original request body for forwarding #6538

Merged
merged 4 commits into from
Apr 5, 2019
Merged

Conversation

jefferai
Copy link
Member

@jefferai jefferai commented Apr 5, 2019

If we are forwarding a request after initial parsing the request body is
already consumed. As a result a forwarded call containing a request body
will have the body be nil. This saves the original request body for a
given request via a TeeReader and uses that in cases of forwarding past
body consumption.

If we are forwarding a request after initial parsing the request body is
already consumed. As a result a forwarded call containing a request body
will have the body be nil. This saves the original request body for a
given request via a TeeReader and uses that in cases of forwarding past
body consumption.
@jefferai jefferai added this to the 1.1.1 milestone Apr 5, 2019
ncabatoff
ncabatoff previously approved these changes Apr 5, 2019
Copy link
Collaborator

@ncabatoff ncabatoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though I'm a little confused why you return a ReadCloser instead of a Reader, given that the only non-nil value returned is a nopCloser.

@vishalnayak
Copy link
Contributor

@ncabatoff NopCloser is a ReadCloser.

@jefferai
Copy link
Member Author

jefferai commented Apr 5, 2019

It's just so that we can directly pass it into r.Body, which expects a ReadCloser. We could wrap it at that time as well -- doesn't really matter.

@jefferai jefferai merged commit b1df69d into master Apr 5, 2019
@jefferai jefferai deleted the request-body-save branch April 5, 2019 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants