From 606d2941023d09436e4173b477908d08a391e426 Mon Sep 17 00:00:00 2001 From: David Belais Date: Fri, 16 Jan 2026 15:07:03 -0800 Subject: [PATCH 1/2] * --- pyproject.toml | 2 +- src/oapi/client.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2c2521c..bcd6c50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/src/oapi/client.py b/src/oapi/client.py index 16ae722..20c7202 100644 --- a/src/oapi/client.py +++ b/src/oapi/client.py @@ -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: @@ -666,7 +666,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, @@ -755,6 +755,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 @@ -781,6 +783,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 From 650979feed47522e4f7d618f1dbf9fc217f26431 Mon Sep 17 00:00:00 2001 From: David Belais Date: Fri, 16 Jan 2026 15:09:53 -0800 Subject: [PATCH 2/2] * --- src/oapi/client.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/oapi/client.py b/src/oapi/client.py index 20c7202..c23b0b6 100644 --- a/src/oapi/client.py +++ b/src/oapi/client.py @@ -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], ...] = (