Add response headers to action response of rest command (#148480)

This commit is contained in:
Jan-Philipp Benecke 2025-07-09 20:37:00 +02:00 committed by GitHub
parent 57083d877e
commit 1b5bbda6b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -205,7 +205,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"decoding_type": "text", "decoding_type": "text",
}, },
) from err ) from err
return {"content": _content, "status": response.status} return {
"content": _content,
"status": response.status,
"headers": dict(response.headers),
}
except TimeoutError as err: except TimeoutError as err:
raise HomeAssistantError( raise HomeAssistantError(

View File

@ -290,6 +290,7 @@ async def test_rest_command_get_response_plaintext(
assert len(aioclient_mock.mock_calls) == 1 assert len(aioclient_mock.mock_calls) == 1
assert response["content"] == "success" assert response["content"] == "success"
assert response["status"] == 200 assert response["status"] == 200
assert response["headers"] == {"content-type": "text/plain"}
async def test_rest_command_get_response_json( async def test_rest_command_get_response_json(
@ -314,6 +315,7 @@ async def test_rest_command_get_response_json(
assert response["content"]["status"] == "success" assert response["content"]["status"] == "success"
assert response["content"]["number"] == 42 assert response["content"]["number"] == 42
assert response["status"] == 200 assert response["status"] == 200
assert response["headers"] == {"content-type": "application/json"}
async def test_rest_command_get_response_malformed_json( async def test_rest_command_get_response_malformed_json(