From 4cf757e188ab21fb81644091f87c24c20bd97c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 5 Jun 2024 21:12:02 +0200 Subject: [PATCH] Add an accept header in JSON request to help 3rd party services like localstack (#1721) --- CHANGELOG.md | 4 ++++ src/Input/GetThingShadowRequest.php | 5 ++++- src/Input/UpdateThingShadowRequest.php | 5 ++++- tests/Unit/Input/GetThingShadowRequestTest.php | 3 ++- tests/Unit/Input/UpdateThingShadowRequestTest.php | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 942539a..c50d9f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## NOT RELEASED +### Changed + +- Add `Accept: application/json` header in request to fix incompatibility with 3rd party providers + ## 1.1.1 ### Changed diff --git a/src/Input/GetThingShadowRequest.php b/src/Input/GetThingShadowRequest.php index 3e8a59f..d0f2871 100644 --- a/src/Input/GetThingShadowRequest.php +++ b/src/Input/GetThingShadowRequest.php @@ -70,7 +70,10 @@ public function getThingName(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/json']; + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; diff --git a/src/Input/UpdateThingShadowRequest.php b/src/Input/UpdateThingShadowRequest.php index 4ed7bfb..1886bfe 100644 --- a/src/Input/UpdateThingShadowRequest.php +++ b/src/Input/UpdateThingShadowRequest.php @@ -87,7 +87,10 @@ public function getThingName(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/json']; + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; diff --git a/tests/Unit/Input/GetThingShadowRequestTest.php b/tests/Unit/Input/GetThingShadowRequestTest.php index 1620918..aa93c99 100644 --- a/tests/Unit/Input/GetThingShadowRequestTest.php +++ b/tests/Unit/Input/GetThingShadowRequestTest.php @@ -17,7 +17,8 @@ public function testRequest(): void // see https://docs.aws.amazon.com/iot/latest/apireference/API_Operations_AWS_IoT_Data_Plane.html/API_GetThingShadow.html $expected = ' GET /things/unit21_hvac/shadow?name=temperature HTTP/1.0 - Content-Type: application/json + Content-type: application/json + Accept: application/json '; self::assertRequestEqualsHttpRequest($expected, $input->request()); diff --git a/tests/Unit/Input/UpdateThingShadowRequestTest.php b/tests/Unit/Input/UpdateThingShadowRequestTest.php index a9e3c65..2ae2746 100644 --- a/tests/Unit/Input/UpdateThingShadowRequestTest.php +++ b/tests/Unit/Input/UpdateThingShadowRequestTest.php @@ -18,7 +18,8 @@ public function testRequest(): void // see https://docs.aws.amazon.com/iot/latest/apireference/API_Operations_AWS_IoT_Data_Plane.html/API_UpdateThingShadow.html $expected = ' POST /things/unit21_hvac/shadow?name=temperature HTTP/1.0 - Content-Type: application/json + Content-type: application/json + Accept: application/json { "state": {