Skip to content

Conversation

@neilverma526-alt
Copy link

Adds max_response_size to requests.request and Session.request to cap response body reads.

  • Introduces requests.exceptions.ContentTooLarge.
  • Enforces limits based on bytes actually read (streaming raises during consumption via iter_content/.content).
  • Ensures connection is closed/released when limit exceeded to avoid pool deadlocks.
  • Keeps behavior unchanged when max_response_size is not provided.

Tests:

  • ./test.sh base
  • ./test.sh new

@neilverma526-alt neilverma526-alt marked this pull request as draft January 21, 2026 12:33
@neilverma526-alt neilverma526-alt marked this pull request as ready for review January 21, 2026 14:07
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