Skip to content

Commit e26cd9d

Browse files
authored
Add an accept header in JSON request to help 3rd party services like localstack (#1721)
1 parent eac89fb commit e26cd9d

19 files changed

+58
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## NOT RELEASED
44

5+
### Changed
6+
7+
- Add `Accept: application/json` header in request to fix incompatibility with 3rd party providers
8+
59
## 2.5.0
610

711
### Added

src/Input/AddLayerVersionPermissionRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ public function getVersionNumber(): ?int
153153
public function request(): Request
154154
{
155155
// Prepare headers
156-
$headers = ['content-type' => 'application/json'];
156+
$headers = [
157+
'Content-Type' => 'application/json',
158+
'Accept' => 'application/json',
159+
];
157160

158161
// Prepare query
159162
$query = [];

src/Input/DeleteFunctionRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ public function getQualifier(): ?string
7676
public function request(): Request
7777
{
7878
// Prepare headers
79-
$headers = ['content-type' => 'application/json'];
79+
$headers = [
80+
'Content-Type' => 'application/json',
81+
'Accept' => 'application/json',
82+
];
8083

8184
// Prepare query
8285
$query = [];

src/Input/GetFunctionConfigurationRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ public function getQualifier(): ?string
7676
public function request(): Request
7777
{
7878
// Prepare headers
79-
$headers = ['content-type' => 'application/json'];
79+
$headers = [
80+
'Content-Type' => 'application/json',
81+
'Accept' => 'application/json',
82+
];
8083

8184
// Prepare query
8285
$query = [];

src/Input/InvocationRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ public function getQualifier(): ?string
154154
public function request(): Request
155155
{
156156
// Prepare headers
157-
$headers = ['content-type' => 'application/json'];
157+
$headers = [
158+
'Content-Type' => 'application/json',
159+
'Accept' => 'application/json',
160+
];
158161
if (null !== $this->invocationType) {
159162
if (!InvocationType::exists($this->invocationType)) {
160163
throw new InvalidArgument(sprintf('Invalid parameter "InvocationType" for "%s". The value "%s" is not a valid "InvocationType".', __CLASS__, $this->invocationType));

src/Input/ListFunctionsRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ public function getMaxItems(): ?int
102102
public function request(): Request
103103
{
104104
// Prepare headers
105-
$headers = ['content-type' => 'application/json'];
105+
$headers = [
106+
'Content-Type' => 'application/json',
107+
'Accept' => 'application/json',
108+
];
106109

107110
// Prepare query
108111
$query = [];

src/Input/ListLayerVersionsRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ public function getMaxItems(): ?int
126126
public function request(): Request
127127
{
128128
// Prepare headers
129-
$headers = ['content-type' => 'application/json'];
129+
$headers = [
130+
'Content-Type' => 'application/json',
131+
'Accept' => 'application/json',
132+
];
130133

131134
// Prepare query
132135
$query = [];

src/Input/ListVersionsByFunctionRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ public function getMaxItems(): ?int
9292
public function request(): Request
9393
{
9494
// Prepare headers
95-
$headers = ['content-type' => 'application/json'];
95+
$headers = [
96+
'Content-Type' => 'application/json',
97+
'Accept' => 'application/json',
98+
];
9699

97100
// Prepare query
98101
$query = [];

src/Input/PublishLayerVersionRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ public function getLicenseInfo(): ?string
151151
public function request(): Request
152152
{
153153
// Prepare headers
154-
$headers = ['content-type' => 'application/json'];
154+
$headers = [
155+
'Content-Type' => 'application/json',
156+
'Accept' => 'application/json',
157+
];
155158

156159
// Prepare query
157160
$query = [];

src/Input/UpdateFunctionConfigurationRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ public function getVpcConfig(): ?VpcConfig
393393
public function request(): Request
394394
{
395395
// Prepare headers
396-
$headers = ['content-type' => 'application/json'];
396+
$headers = [
397+
'Content-Type' => 'application/json',
398+
'Accept' => 'application/json',
399+
];
397400

398401
// Prepare query
399402
$query = [];

tests/Unit/Input/AddLayerVersionPermissionRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public function testRequest(): void
2424

2525
$expected = '
2626
POST /2018-10-31/layers/nodejs/versions/2/policy?RevisionId=123456 HTTP/1.0
27-
Content-Type: application/json
27+
Content-type: application/json
28+
Accept: application/json
2829
2930
{
3031
"Action": "lambda:GetLayerVersion",

tests/Unit/Input/DeleteFunctionRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public function testRequest(): void
1717
// see example-1.json from SDK
1818
$expected = '
1919
DELETE /2015-03-31/functions/my-function?Qualifier=4711 HTTP/1.0
20-
Content-Type: application/json
20+
Content-type: application/json
21+
Accept: application/json
2122
';
2223

2324
self::assertRequestEqualsHttpRequest($expected, $input->request());

tests/Unit/Input/GetFunctionConfigurationRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public function testRequest(): void
1717
// see https://docs.aws.amazon.com/lambda/latest/APIReference/API_GetFunctionConfiguration.html
1818
$expected = '
1919
GET /2015-03-31/functions/test-func/configuration?Qualifier=change HTTP/1.0
20-
Content-Type: application/json
20+
Content-type: application/json
21+
Accept: application/json
2122
';
2223
self::assertRequestEqualsHttpRequest($expected, $input->request());
2324
}

tests/Unit/Input/InvocationRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public function testRequest(): void
2424

2525
$expected = '
2626
POST /2015-03-31/functions/MyFunction/invocations?Qualifier=1 HTTP/1.0
27-
Content-Type: application/json
27+
Content-type: application/json
28+
Accept: application/json
2829
x-amz-invocation-type: Event
2930
x-amz-log-type: Tail
3031
x-amz-client-context: MyApp

tests/Unit/Input/ListFunctionsRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public function testRequest(): void
1919
// see https://docs.aws.amazon.com/lambda/latest/APIReference/API_ListFunctions.html
2020
$expected = '
2121
GET /2015-03-31/functions/?FunctionVersion=ALL&Marker=xxyy&MasterRegion=eu-central-1&MaxItems=1337 HTTP/1.1
22-
Content-Type: application/json
22+
Content-type: application/json
23+
Accept: application/json
2324
';
2425

2526
self::assertRequestEqualsHttpRequest($expected, $input->request());

tests/Unit/Input/ListLayerVersionsRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public function testRequest(): void
2020

2121
$expected = '
2222
GET /2018-10-31/layers/demo/versions?CompatibleRuntime=nodejs12.x HTTP/1.0
23-
Content-Type: application/json
23+
Content-type: application/json
24+
Accept: application/json
2425
';
2526

2627
self::assertRequestEqualsHttpRequest($expected, $input->request());

tests/Unit/Input/ListVersionsByFunctionRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public function testRequest(): void
1818
// see example-1.json from SDK
1919
$expected = '
2020
GET /2015-03-31/functions/MyFunction/versions?Marker=xxyy&MaxItems=1337 HTTP/1.0
21-
Content-Type: application/json
21+
Content-type: application/json
22+
Accept: application/json
2223
2324
';
2425

tests/Unit/Input/PublishLayerVersionRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testRequest(): void
2929
// see https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html
3030
$expected = '
3131
POST /2018-10-31/layers/demo/versions HTTP/1.0
32-
Content-Type: application/json
32+
Content-type: application/json
33+
Accept: application/json
3334
3435
{
3536
"Description": "small description",

tests/Unit/Input/UpdateFunctionConfigurationRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function testRequest(): void
6464
// see https://docs.aws.amazon.com/lambda/latest/APIReference/API_UpdateFunctionConfiguration.html
6565
$expected = '
6666
PUT /2015-03-31/functions/test-func/configuration HTTP/1.0
67-
Content-Type: application/json
67+
Content-type: application/json
68+
Accept: application/json
6869
6970
{
7071
"DeadLetterConfig": {

0 commit comments

Comments
 (0)