Fix ingress sending an empty body for GET requests (#101917)
This commit is contained in:
parent
11740d1e68
commit
36e1c740fd
3 changed files with 19 additions and 4 deletions
|
@ -164,7 +164,7 @@ class HassIOView(HomeAssistantView):
|
||||||
method=request.method,
|
method=request.method,
|
||||||
url=f"http://{self._host}/{quote(path)}",
|
url=f"http://{self._host}/{quote(path)}",
|
||||||
params=request.query,
|
params=request.query,
|
||||||
data=request.content,
|
data=request.content if request.method != "GET" else None,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=_get_timeout(path),
|
timeout=_get_timeout(path),
|
||||||
)
|
)
|
||||||
|
|
|
@ -162,7 +162,7 @@ class HassIOIngress(HomeAssistantView):
|
||||||
headers=source_header,
|
headers=source_header,
|
||||||
params=request.query,
|
params=request.query,
|
||||||
allow_redirects=False,
|
allow_redirects=False,
|
||||||
data=request.content,
|
data=request.content if request.method != "GET" else None,
|
||||||
timeout=ClientTimeout(total=None),
|
timeout=ClientTimeout(total=None),
|
||||||
skip_auto_headers={hdrs.CONTENT_TYPE},
|
skip_auto_headers={hdrs.CONTENT_TYPE},
|
||||||
) as result:
|
) as result:
|
||||||
|
|
|
@ -450,11 +450,26 @@ async def test_backup_download_headers(
|
||||||
|
|
||||||
async def test_stream(hassio_client, aioclient_mock: AiohttpClientMocker) -> None:
|
async def test_stream(hassio_client, aioclient_mock: AiohttpClientMocker) -> None:
|
||||||
"""Verify that the request is a stream."""
|
"""Verify that the request is a stream."""
|
||||||
aioclient_mock.get("http://127.0.0.1/app/entrypoint.js")
|
content_type = "multipart/form-data; boundary='--webkit'"
|
||||||
await hassio_client.get("/api/hassio/app/entrypoint.js", data="test")
|
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)
|
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(
|
async def test_entrypoint_cache_control(
|
||||||
hassio_client, aioclient_mock: AiohttpClientMocker
|
hassio_client, aioclient_mock: AiohttpClientMocker
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue