diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index 8ba389f9054..d86f1b7dc5c 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -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/")) diff --git a/tests/components/hassio/test_ingress.py b/tests/components/hassio/test_ingress.py index c8255ac0496..791337079f0 100644 --- a/tests/components/hassio/test_ingress.py +++ b/tests/components/hassio/test_ingress.py @@ -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(