From 5af6add332593ab78487198ca08208b34c228024 Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Fri, 15 Nov 2024 11:34:06 +0000
Subject: [PATCH 1/5] Version 0.28.0
---
CHANGELOG.md | 2 +-
README.md | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e7ad03c086..1936ef0c38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
-## [Unreleased]
+## 0.28.0 (15th November, 2024)
The 0.28 release includes a limited set of backwards incompatible changes.
diff --git a/README.md b/README.md
index d5d2148713..23992d9c24 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,7 @@
-HTTPX is a fully featured HTTP client library for Python 3. It includes **an integrated
-command line client**, has support for both **HTTP/1.1 and HTTP/2**, and provides both **sync
-and async APIs**.
+HTTPX is a fully featured HTTP client library for Python 3. It includes **an integrated command line client**, has support for both **HTTP/1.1 and HTTP/2**, and provides both **sync and async APIs**.
---
From 00b80df5675edbad8b8982f907b53471ab8f13b8 Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Fri, 15 Nov 2024 11:39:08 +0000
Subject: [PATCH 2/5] Version 0.28.0
---
httpx/__version__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/httpx/__version__.py b/httpx/__version__.py
index 5eaaddbac9..0a684ac3a9 100644
--- a/httpx/__version__.py
+++ b/httpx/__version__.py
@@ -1,3 +1,3 @@
__title__ = "httpx"
__description__ = "A next generation HTTP client, for Python 3."
-__version__ = "0.27.2"
+__version__ = "0.28.0"
From 4363c09de997bae90749f65cee586307d598a4b2 Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Fri, 22 Nov 2024 11:04:15 +0000
Subject: [PATCH 3/5] Handle empty zstd responses
---
httpx/_decoders.py | 4 ++++
test | 1 +
tests/test_decoders.py | 19 +++++++++++++++++++
3 files changed, 24 insertions(+)
create mode 100644 test
diff --git a/httpx/_decoders.py b/httpx/_decoders.py
index 180898c53f..899dfada87 100644
--- a/httpx/_decoders.py
+++ b/httpx/_decoders.py
@@ -175,9 +175,11 @@ def __init__(self) -> None:
) from None
self.decompressor = zstandard.ZstdDecompressor().decompressobj()
+ self.seen_data = False
def decode(self, data: bytes) -> bytes:
assert zstandard is not None
+ self.seen_data = True
output = io.BytesIO()
try:
output.write(self.decompressor.decompress(data))
@@ -190,6 +192,8 @@ def decode(self, data: bytes) -> bytes:
return output.getvalue()
def flush(self) -> bytes:
+ if not self.seen_data:
+ return b""
ret = self.decompressor.flush() # note: this is a no-op
if not self.decompressor.eof:
raise DecodingError("Zstandard data is incomplete") # pragma: no cover
diff --git a/test b/test
new file mode 100644
index 0000000000..a7c01bc6a4
--- /dev/null
+++ b/test
@@ -0,0 +1 @@
+# TLS secrets log file, generated by OpenSSL / Python
diff --git a/tests/test_decoders.py b/tests/test_decoders.py
index bcbb18bb0e..9ffaba189d 100644
--- a/tests/test_decoders.py
+++ b/tests/test_decoders.py
@@ -100,6 +100,25 @@ def test_zstd_decoding_error():
)
+def test_zstd_empty():
+ headers = [(b"Content-Encoding", b"zstd")]
+ response = httpx.Response(200, headers=headers, content=b"")
+ assert response.content == b""
+
+
+def test_zstd_truncated():
+ body = b"test 123"
+ compressed_body = zstd.compress(body)
+
+ headers = [(b"Content-Encoding", b"zstd")]
+ with pytest.raises(httpx.DecodingError):
+ httpx.Response(
+ 200,
+ headers=headers,
+ content=compressed_body[1:3],
+ )
+
+
def test_zstd_multiframe():
# test inspired by urllib3 test suite
data = (
From 1ca3e20f66978ec70c058eca6d544cde8d4cdb64 Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Fri, 22 Nov 2024 11:06:35 +0000
Subject: [PATCH 4/5] Not yet released
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1936ef0c38..0122ca26c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
-## 0.28.0 (15th November, 2024)
+## 0.28.0 (...)
The 0.28 release includes a limited set of backwards incompatible changes.
From 8f90ea965cafe92733a4f3a474666830191251ad Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Fri, 22 Nov 2024 11:07:12 +0000
Subject: [PATCH 5/5] Drop test file
---
test | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 test
diff --git a/test b/test
deleted file mode 100644
index a7c01bc6a4..0000000000
--- a/test
+++ /dev/null
@@ -1 +0,0 @@
-# TLS secrets log file, generated by OpenSSL / Python