Avoid compressing application (tarfile) downloads from supervisor (#110224)

This commit is contained in:
J. Nick Koston 2024-02-21 12:45:47 -06:00 committed by GitHub
parent a0b185d06d
commit d6fac87876
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -224,4 +224,10 @@ def should_compress(content_type: str) -> bool:
"""Return if we should compress a response."""
if content_type.startswith("image/"):
return "svg" in content_type
if content_type.startswith("application/"):
return (
"json" in content_type
or "xml" in content_type
or "javascript" in content_type
)
return not content_type.startswith(("video/", "audio/", "font/"))

View File

@ -368,7 +368,7 @@ async def test_ingress_request_get_compressed(
aioclient_mock.get(
f"http://127.0.0.1/ingress/{build_type[0]}/{build_type[1]}",
text=body,
headers={"Content-Length": len(body)},
headers={"Content-Length": len(body), "Content-Type": "text/plain"},
)
resp = await hassio_noauth_client.get(
@ -403,6 +403,7 @@ async def test_ingress_request_get_compressed(
"image/jpeg",
"font/woff2",
"video/mp4",
"application/tar",
],
)
async def test_ingress_request_not_compressed(
@ -458,6 +459,7 @@ async def test_ingress_request_with_charset_in_content_type(
"text/html",
"application/javascript",
"text/plain",
"application/json",
],
)
async def test_ingress_request_compressed(