Skip to content

Commit

Permalink
Add an accept header in JSON request to help 3rd party services like …
Browse files Browse the repository at this point in the history
…localstack (#1721)
  • Loading branch information
jderusse authored Jun 5, 2024
1 parent 32a3baa commit 4cf757e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Input/GetThingShadowRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Input/UpdateThingShadowRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/GetThingShadowRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/UpdateThingShadowRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 4cf757e

Please sign in to comment.