Skip to content

Incompatible with urllib3 `read(size, decode_content=True) #902

Open
@pjrobertson

Description

@pjrobertson

urllib3 allows the kwargs decode_content=None and cache_content=False.

See: https://urllib3.readthedocs.io/en/stable/reference/urllib3.response.html#urllib3.response.BaseHTTPResponse.read

If trying to patch a library that uses something like:

myresponse.read(decode_content=True) then patching failes with:

Editing VCRHTTPResponse.read as follows fixes the issue:

    def read(self, *args, **kwargs):
        # urllib3 allows the kwarg 'decode_content' but BytesIO does not support it
        kwargs.pop("decode_content", None)
        return self._content.read(*args, **kwargs)

I'm not sure if this is the way to go though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions