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

Why limit draining response body? #82

Closed
Richtermeister opened this issue Feb 15, 2020 · 2 comments
Closed

Why limit draining response body? #82

Richtermeister opened this issue Feb 15, 2020 · 2 comments

Comments

@Richtermeister
Copy link

Hi there, fantastic library! I just have a question. Why is the draining of response bodies limited to 4096 bytes? https://github.com/hashicorp/go-retryablehttp/blob/master/client.go#L60

Wouldn't this mean that an error-response with a body larger than 4096 bytes would fail to be drained completely and thus would leave behind an unusable connection?

Thank you for helping me understand this particular decision.

@dmarkhas
Copy link

@Richtermeister Yes, however consider a situation that the response body is 1GB - in this case you would prefer to pay the penalty of creating a new connection, over reading so much data over the network, just to discard it as soon as you get it.

I found this discussion very insightful:
google/go-github#317

@ryanuber
Copy link
Member

Hey @Richtermeister , thanks for opening this, and sorry for our delay in response! @dmarkhas gave a perfect answer already. We want to reuse connections wherever possible, but if it means reading a large amount of data then the gains become losses.

Hope that helps!

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

No branches or pull requests

3 participants