mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix ingress sending an empty body for GET requests (#101917)
This commit is contained in:
parent
11740d1e68
commit
36e1c740fd
@ -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),
|
||||
)
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user