Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pjrobertson opened this issue Jan 13, 2025 · 0 comments
Open

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

pjrobertson opened this issue Jan 13, 2025 · 0 comments

Comments

@pjrobertson
Copy link

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.

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

No branches or pull requests

1 participant