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

Restore request body after reading in sign method #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruudk
Copy link

@ruudk ruudk commented Nov 8, 2024

Issue #, if available:
#225

Description of changes:
The problem is the the sign method in ProxyClient reads the req.Body and that results in a closed reader.

When the request is actually send to the transport later, the body cannot be read and results in a body length of 0 which does not match the passed req.ContentLength.

We tried to write tests for this, but the tests are not fully matching the real world because:

  • they use io.NopCloser
  • they use a HTTP mock client that doesn't actually read the body to send to the proxy (makes sense, its a mock, but it's different than the actual implementation)

If you have advice how to test this properly, we're all ears.

Fixes awslabs#225

The problem is the the `sign` method in ProxyClient reads the `req.Body` and that results
in a closed reader.

When the request is actually send to the transport later, the body cannot be read and results
in a body length of 0 which does not match the passed req.ContentLength.

We tried to write tests for this, but the tests are not fully matching the real world because:
* they use io.NopCloser
* they use a HTTP mock client that doesn't actually read the body to send to the proxy (makes sense,
its a mock, but it's different than the actual implementation)
@ruudk
Copy link
Author

ruudk commented Nov 8, 2024

@roystchiang @rapphil Could you please approve the workflow? If you have time, please advice how to write tests for this.

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.

1 participant