getsentry / responses

A utility for mocking out the Python Requests library.
Apache License 2.0
4.14k stars 354 forks source link

`delete` with content will fail #656

Closed JohnVillalovos closed 1 year ago

JohnVillalovos commented 1 year ago

Describe the bug

Reproducer in https://github.com/getsentry/responses/pull/655/

    def generate():
        # Special case for urllib3.
        if hasattr(self.raw, "stream"):
            try:
                yield from self.raw.stream(chunk_size, decode_content=True)
            except ProtocolError as e:
>               raise ChunkedEncodingError(e)
E               requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(29 bytes read, -29 more expected)', IncompleteRead(29 bytes read, -29 more expected))

Additional context

No response

Version of responses

0.23.2

Steps to Reproduce

Use https://github.com/getsentry/responses/pull/655/ and run tox

Expected Result

No error

Actual Result

Error

JohnVillalovos commented 1 year ago

So after further investigation this seems a requests issue where if it is a 204 (No Content) then it sets the expected length to 0.