Skip to content

Commit

Permalink
fix based on kevin1024/vcrpy#844
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivan-sean committed Jul 16, 2024
1 parent db764f0 commit 2824cfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion vcr/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def replace_post_data_parameters(request, replacements):
if sep is None:
new_splits.append((k, sep, ov))
else:
rk = k.decode("utf-8")
try:
rk = k.decode("utf-8")
except UnicodeDecodeError:
rk = k
if rk not in replacements:
new_splits.append((k, sep, ov))
else:
Expand Down
7 changes: 6 additions & 1 deletion vcr/stubs/httpx_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ def _from_serialized_response(request, serialized_response, history=None):


def _make_vcr_request(httpx_request, **kwargs):
body = httpx_request.read().decode("utf-8")
body_bytes = httpx_request.read()
try:
body = body_bytes.decode("utf-8")
except UnicodeDecodeError:
body = body_bytes

uri = str(httpx_request.url)
headers = dict(httpx_request.headers)
return VcrRequest(httpx_request.method, uri, body, headers)
Expand Down

0 comments on commit 2824cfd

Please sign in to comment.