Closed Kludex closed 1 year ago
Thanks @mgorny.
Ok. That makes sense... We are just "faking" the content-encoding there, we should really encode it with brotli, or choose a different encoding maybe, so we don't add the dependency?
Well, it passed for me if I used a totally random text
encoding, i.e.:
diff --git a/tests/middleware/test_gzip.py b/tests/middleware/test_gzip.py
index 74b09e4..b6ec1f3 100644
--- a/tests/middleware/test_gzip.py
+++ b/tests/middleware/test_gzip.py
@@ -86,7 +86,7 @@ def test_gzip_ignored_for_responses_with_encoding_set(test_client_factory):
streaming = generator(bytes=b"x" * 400, count=10)
return StreamingResponse(
- streaming, status_code=200, headers={"Content-Encoding": "br"}
+ streaming, status_code=200, headers={"Content-Encoding": "text"}
)
app = Starlette(
@@ -95,8 +95,8 @@ def test_gzip_ignored_for_responses_with_encoding_set(test_client_factory):
)
client = test_client_factory(app)
- response = client.get("/", headers={"accept-encoding": "gzip, br"})
+ response = client.get("/", headers={"accept-encoding": "gzip, text"})
assert response.status_code == 200
assert response.text == "x" * 4000
- assert response.headers["Content-Encoding"] == "br"
+ assert response.headers["Content-Encoding"] == "text"
assert "Content-Length" not in response.headers
However, I'm not sure how portable is that.
Ok. PR welcome.
Closed by #1962
Discussed in https://github.com/encode/starlette/discussions/1956