diff --git a/homeassistant/components/hassio/ingress.py b/homeassistant/components/hassio/ingress.py index e673c3a70e9..ca6764cfa34 100644 --- a/homeassistant/components/hassio/ingress.py +++ b/homeassistant/components/hassio/ingress.py @@ -11,6 +11,7 @@ from urllib.parse import quote import aiohttp from aiohttp import ClientTimeout, ClientWebSocketResponse, hdrs, web +from aiohttp.helpers import must_be_empty_body from aiohttp.web_exceptions import HTTPBadGateway, HTTPBadRequest from multidict import CIMultiDict from yarl import URL @@ -184,13 +185,16 @@ class HassIOIngress(HomeAssistantView): content_type = "application/octet-stream" # Simple request - if result.status in (204, 304) or ( + if (empty_body := must_be_empty_body(result.method, result.status)) or ( content_length is not UNDEFINED and (content_length_int := int(content_length)) <= MAX_SIMPLE_RESPONSE_SIZE ): # Return Response - body = await result.read() + if empty_body: + body = None + else: + body = await result.read() simple_response = web.Response( headers=headers, status=result.status,