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

Recording requests does not work for non-UTF8 data #477

Open
samamorgan opened this issue Nov 30, 2023 · 0 comments
Open

Recording requests does not work for non-UTF8 data #477

samamorgan opened this issue Nov 30, 2023 · 0 comments

Comments

@samamorgan
Copy link

samamorgan commented Nov 30, 2023

from httpretty import HTTPretty
import requests


with HTTPretty.record("image.json", allow_net_connect=True):
    requests.get("https://httpbin.org/image/jpeg")

This raises UnicodeDecodeError because the record method is always trying to decode the response body.

https://github.com/gabrielfalcao/HTTPretty/blob/main/httpretty/core.py#L1540

I assume the same thing will happen if I try to record a POST request with binary data because of:

https://github.com/gabrielfalcao/HTTPretty/blob/main/httpretty/core.py#L1535

@samamorgan samamorgan changed the title Recording requests does not work for non-text data Recording requests does not work for non-UTF8 data Nov 30, 2023
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