Skip to content

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

Open
@samamorgan

Description

@samamorgan
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

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