Skip to content

Test verifying that ChunkedEncodingError is raised on an invalid Transfer-Encoding: chunked response.#5906

Merged
nateprewitt merged 1 commit intopsf:mainfrom
theGOTOguy:addchunkedencodingerrortest
Aug 25, 2021
Merged

Test verifying that ChunkedEncodingError is raised on an invalid Transfer-Encoding: chunked response.#5906
nateprewitt merged 1 commit intopsf:mainfrom
theGOTOguy:addchunkedencodingerrortest

Conversation

@theGOTOguy
Copy link
Copy Markdown
Contributor

This logic is not currently exercised anywhere in requests' tests.

For context, most errors that occur during the process of handling a request can be retried through urllib3's Retry. Currently, chunked encoding bypasses this, leading to a situation where users of requests are left to roll their own custom error handling for chunked encoding. #5664 seeks to remedy that, but there are two issues:

First, the current logic around chunked encoding has limited tests, and there is concern that accepting #5664 would introduce a regression.
Second, switching from requests' internal exceptions to urllib3's exceptions is a breaking change that will require appropriate notification to existing users.

This is a first step towards addressing both issues by exercising the chunked encoding logic internally, introducing a test that will break when requests switches to using urllib3's exceptions for chunked encoding, and providing a simple example to start with for any who seek to write further tests for the chunked encoding logic.

…invalid Transfer-Encoding: chunked response is returned.
Copy link
Copy Markdown
Member

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

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

Hey @theGOTOguy, thanks for the contribution. I think the concern of changing from our current chunked implementation to urllib3 is more with request serialization rather than response deserialization.

That said, you're right we're not testing this behavior anywhere when we probably should. We can merge this as a general testing improvement.

@nateprewitt nateprewitt merged commit 2d30aeb into psf:main Aug 25, 2021
@theGOTOguy
Copy link
Copy Markdown
Contributor Author

I appreciate the feedback on what tests are needed, @nateprewitt. I will look into request serialization tests next.

@theGOTOguy theGOTOguy deleted the addchunkedencodingerrortest branch August 25, 2021 06:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants