svn commit: r1934949 - in httpd/httpd/trunk/test/pytest_suite: apache_pytest tests/t/apache tests/t/modules

[email protected]
Newsgroups gmane.comp.apache.cvs
Message-ID <178052129805.2517051.12016988155520382006@svn03-he-fi>
Author: jim
Date: Wed Jun  3 21:14:57 2026
New Revision: 1934949

Log:
test/pytest_suite: fix deflate round-trip tests to use raw gzip bytes

httpx auto-decompresses gzip responses, so .content returned the decoded
plaintext rather than the gzip stream. Re-POSTing that plaintext with
Content-Encoding: gzip made mod_deflate's inflate input filter fail,
breaking the round-trip assertions in test_pr49328 and test_deflate.

Add a GET_RAW client helper that streams the response and reads iter_raw(),
returning the body undecoded (the analog of LWP not auto-decoding), and use
it in both tests so they exercise a genuine gzip -> inflate round-trip.

Modified:
   httpd/httpd/trunk/test/pytest_suite/apache_pytest/client.py
   httpd/httpd/trunk/test/pytest_suite/tests/t/apache/test_pr49328.py
   httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_deflate.py

Modified: httpd/httpd/trunk/test/pytest_suite/apache_pytest/client.py
==============================================================================
--- httpd/httpd/trunk/test/pytest_suite/apache_pytest/client.py	Wed Jun  3 20:35:56 2026	(r1934948)
+++ httpd/httpd/trunk/test/pytest_suite/apache_pytest/client.py	Wed Jun  3 21:14:57 2026	(r1934949)
@@ -272,6 +272,34 @@ class TestClient:
     def GET(self, path: str, **kwargs: object) -> httpx.Response:
         return self._request("GET", path, **kwargs)
 
+    def _raw_body(
+        self,
+        method: str,
+        path: str,
+        *,
+        cert: str | None = None,
+        **kwargs: object,
+    ) -> bytes:
+        """Return the response body WITHOUT content-decoding.
+
+        httpx transparently inflates gzip/deflate responses, so ``.content`` is
+        the decoded plaintext. The mod_deflate round-trip tests need the raw
+        compressed bytes (to re-POST them through the inflate input filter), so
+        stream the response and read ``iter_raw()``, which yields the bytes as
+        they came off the wire -- the analog of LWP not auto-decoding.
+        """
+        client = self._client_for(cert) if cert is not None else self._client
+        request = client.build_request(method, self._url(path), **kwargs)  # type: ignore[arg-type]
+        response = client.send(request, stream=True)
+        try:
+            return b"".join(response.iter_raw())
+        finally:
+            response.close()
+
+    def GET_RAW(self, path: str, **kwargs: object) -> bytes:
+        """GET ``path`` and return the raw, undecoded response body bytes."""
+        return self._raw_body("GET", path, **kwargs)
+
     def HEAD(self, path: str, **kwargs: object) -> httpx.Response:
         return self._request("HEAD", path, **kwargs)
 

Modified: httpd/httpd/trunk/test/pytest_suite/tests/t/apache/test_pr49328.py
==============================================================================
--- httpd/httpd/trunk/test/pytest_suite/tests/t/apache/test_pr49328.py	Wed Jun  3 20:35:56 2026	(r1934948)
+++ httpd/httpd/trunk/test/pytest_suite/tests/t/apache/test_pr49328.py	Wed Jun  3 21:14:57 2026	(r1934949)
@@ -14,7 +14,9 @@ URI = "/modules/filter/pr49328/pr49328.s
 
 @need_module("filter", "include", "deflate")
 def test_pr49328(http):
-    content = http.GET(URI, headers={"Accept-Encoding": "gzip"}).content
+    # GET_RAW: keep the gzip stream undecoded so we can re-POST it through the
+    # inflate input filter (httpx would otherwise auto-decompress .content).
+    content = http.GET_RAW(URI, headers={"Accept-Encoding": "gzip"})
     deflated = http.POST_BODY(
         INFLATOR, content=content, headers={"Content-Encoding": "gzip"}
     )

Modified: httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_deflate.py
==============================================================================
--- httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_deflate.py	Wed Jun  3 20:35:56 2026	(r1934948)
+++ httpd/httpd/trunk/test/pytest_suite/tests/t/modules/test_deflate.py	Wed Jun  3 21:14:57 2026	(r1934949)
@@ -54,16 +54,10 @@ def test_deflate(http):
     for uri in _uris(http):
         original = http.GET_BODY(uri)
 
-        # httpx auto-decompresses; ask the server explicitly for the raw gzip
-        # by reading .content with the gzip Accept-Encoding, then re-POST it.
-        deflated_resp = http.GET(uri, headers=DEFLATE_HEADERS)
-        # We need the raw gzip bytes to re-inflate; httpx exposes the (already
-        # decoded) text, so reconstruct via the same endpoint the Perl test
-        # used: POST the deflated bytes back. To obtain the raw deflated bytes
-        # without httpx auto-decoding we disable decoding through a header probe;
-        # fall back to comparing decoded bodies, which is what the round-trip
-        # asserts anyway.
-        deflated = deflated_resp.content
+        # httpx auto-decompresses, so GET_RAW reads the body undecoded to get
+        # the actual gzip stream; re-POST it through the inflate input filter
+        # (echo_post) and assert it round-trips back to the original.
+        deflated = http.GET_RAW(uri, headers=DEFLATE_HEADERS)
 
         deflated_str_q0 = http.GET_BODY(uri, headers=DEFLATE_HEADERS_Q0)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.