diff --git a/homeassistant/components/rest_command/__init__.py b/homeassistant/components/rest_command/__init__.py index c6a4206de4a..0a9632b864d 100644 --- a/homeassistant/components/rest_command/__init__.py +++ b/homeassistant/components/rest_command/__init__.py @@ -205,7 +205,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: "decoding_type": "text", }, ) from err - return {"content": _content, "status": response.status} + return { + "content": _content, + "status": response.status, + "headers": dict(response.headers), + } except TimeoutError as err: raise HomeAssistantError( diff --git a/tests/components/rest_command/test_init.py b/tests/components/rest_command/test_init.py index 97ef29dfaca..5549aa67815 100644 --- a/tests/components/rest_command/test_init.py +++ b/tests/components/rest_command/test_init.py @@ -290,6 +290,7 @@ async def test_rest_command_get_response_plaintext( assert len(aioclient_mock.mock_calls) == 1 assert response["content"] == "success" assert response["status"] == 200 + assert response["headers"] == {"content-type": "text/plain"} 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"]["number"] == 42 assert response["status"] == 200 + assert response["headers"] == {"content-type": "application/json"} async def test_rest_command_get_response_malformed_json(