Skip to content
Merged

* #68

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "oapi"
version = "2.8.1"
version = "2.8.2"
description = "A library for generating web API clients from OpenAPI documents"
readme = "README.md"
license = "MIT"
Expand Down
12 changes: 6 additions & 6 deletions src/oapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def _get_request_curl_header_item(item: tuple[str, str]) -> str:
)
)
)
if content_encoding:
if data and content_encoding:
data = _decode_content(data, content_encoding)
repr_data: str = ""
if data:
Expand Down Expand Up @@ -631,10 +631,6 @@ def _represent_http_response(
censored_headers: tuple[str, ...] = (),
) -> str:
data = HTTPResponse.read(response) if data is None else data
if data:
content_encoding: str | None = response.getheader("Content-encoding")
if content_encoding:
data = _decode_content(data, content_encoding)
if censored_headers:
censored_headers = tuple(map(str.lower, censored_headers))
header_items: tuple[tuple[str, typing.Any], ...] = (
Expand Down Expand Up @@ -666,7 +662,7 @@ def response_read(amt: int | None = None) -> bytes:
content_encoding: str | None = response.headers.get(
"Content-encoding"
)
if content_encoding:
if data and content_encoding:
data = _decode_content(
data,
content_encoding,
Expand Down Expand Up @@ -755,6 +751,8 @@ def _remove_none(


def _encode_content(data: bytes, content_encoding: str) -> bytes:
if not data:
return data
if "," in content_encoding:
# Encode content in the order provided
content_encodings: str
Expand All @@ -781,6 +779,8 @@ def _encode_content(data: bytes, content_encoding: str) -> bytes:


def _decode_content(data: bytes, content_encoding: str) -> bytes:
if not data:
return data
if "," in content_encoding:
# Decode content in reverse order
content_encodings: str
Expand Down