fix(http): bound response body reads to 4 MB#3604
Open
karan-vk wants to merge 2 commits into
Open
Conversation
Read response bodies incrementally in the reqwest, reqwest-blocking and hyper clients and truncate at the limit instead of buffering without bound, so a misbehaving endpoint cannot exhaust memory. Truncation is deliberately not an error so oversized responses do not trigger exporter retries. The hyper client no longer reads bodies of non-success responses. Fixes open-telemetry#3439
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3604 +/- ##
=======================================
+ Coverage 83.2% 83.3% +0.1%
=======================================
Files 130 130
Lines 28246 28349 +103
=======================================
+ Hits 23506 23636 +130
+ Misses 4740 4713 -27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3439
Changes
Response bodies in the reqwest, reqwest-blocking and hyper clients are now read incrementally and truncated at 4 MB instead of being buffered without bound, so a misbehaving or malicious endpoint cannot exhaust memory. The hyper client no longer reads response bodies for non-success statuses.
Follows the review feedback on the stale predecessor #3501:
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes