diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index cabe6f085ba..419d80484cf 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -164,7 +164,7 @@ class HassIOView(HomeAssistantView): method=request.method, url=f"http://{self._host}/{quote(path)}", params=request.query, - data=request.content, + data=request.content if request.method != "GET" else None, headers=headers, timeout=_get_timeout(path), ) diff --git a/homeassistant/components/hassio/ingress.py b/homeassistant/components/hassio/ingress.py index dc4f3234b60..b8c5873b967 100644 --- a/homeassistant/components/hassio/ingress.py +++ b/homeassistant/components/hassio/ingress.py @@ -162,7 +162,7 @@ class HassIOIngress(HomeAssistantView): headers=source_header, params=request.query, allow_redirects=False, - data=request.content, + data=request.content if request.method != "GET" else None, timeout=ClientTimeout(total=None), skip_auto_headers={hdrs.CONTENT_TYPE}, ) as result: diff --git a/tests/components/hassio/test_http.py b/tests/components/hassio/test_http.py index e659fbe4b8f..2e14c21f20a 100644 --- a/tests/components/hassio/test_http.py +++ b/tests/components/hassio/test_http.py @@ -450,11 +450,26 @@ async def test_backup_download_headers( async def test_stream(hassio_client, aioclient_mock: AiohttpClientMocker) -> None: """Verify that the request is a stream.""" - aioclient_mock.get("http://127.0.0.1/app/entrypoint.js") - await hassio_client.get("/api/hassio/app/entrypoint.js", data="test") + content_type = "multipart/form-data; boundary='--webkit'" + aioclient_mock.post("http://127.0.0.1/backups/new/upload") + resp = await hassio_client.post( + "/api/hassio/backups/new/upload", headers={"Content-Type": content_type} + ) + # Check we got right response + assert resp.status == HTTPStatus.OK assert isinstance(aioclient_mock.mock_calls[-1][2], StreamReader) +async def test_simple_get_no_stream( + hassio_client, aioclient_mock: AiohttpClientMocker +) -> None: + """Verify that a simple GET request is not a stream.""" + aioclient_mock.get("http://127.0.0.1/app/entrypoint.js") + resp = await hassio_client.get("/api/hassio/app/entrypoint.js") + assert resp.status == HTTPStatus.OK + assert aioclient_mock.mock_calls[-1][2] is None + + async def test_entrypoint_cache_control( hassio_client, aioclient_mock: AiohttpClientMocker ) -> None: