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 eac89fb commit e26cd9d
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 18 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

## 2.5.0

### Added
Expand Down
5 changes: 4 additions & 1 deletion src/Input/AddLayerVersionPermissionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ public function getVersionNumber(): ?int
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/DeleteFunctionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public function getQualifier(): ?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/GetFunctionConfigurationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public function getQualifier(): ?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/InvocationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ public function getQualifier(): ?string
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/json'];
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];
if (null !== $this->invocationType) {
if (!InvocationType::exists($this->invocationType)) {
throw new InvalidArgument(sprintf('Invalid parameter "InvocationType" for "%s". The value "%s" is not a valid "InvocationType".', __CLASS__, $this->invocationType));
Expand Down
5 changes: 4 additions & 1 deletion src/Input/ListFunctionsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public function getMaxItems(): ?int
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/ListLayerVersionsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ public function getMaxItems(): ?int
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/ListVersionsByFunctionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public function getMaxItems(): ?int
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/PublishLayerVersionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ public function getLicenseInfo(): ?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/UpdateFunctionConfigurationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ public function getVpcConfig(): ?VpcConfig
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/AddLayerVersionPermissionRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function testRequest(): void

$expected = '
POST /2018-10-31/layers/nodejs/versions/2/policy?RevisionId=123456 HTTP/1.0
Content-Type: application/json
Content-type: application/json
Accept: application/json
{
"Action": "lambda:GetLayerVersion",
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/DeleteFunctionRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function testRequest(): void
// see example-1.json from SDK
$expected = '
DELETE /2015-03-31/functions/my-function?Qualifier=4711 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/GetFunctionConfigurationRequestTest.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/lambda/latest/APIReference/API_GetFunctionConfiguration.html
$expected = '
GET /2015-03-31/functions/test-func/configuration?Qualifier=change 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/InvocationRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function testRequest(): void

$expected = '
POST /2015-03-31/functions/MyFunction/invocations?Qualifier=1 HTTP/1.0
Content-Type: application/json
Content-type: application/json
Accept: application/json
x-amz-invocation-type: Event
x-amz-log-type: Tail
x-amz-client-context: MyApp
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/ListFunctionsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/lambda/latest/APIReference/API_ListFunctions.html
$expected = '
GET /2015-03-31/functions/?FunctionVersion=ALL&Marker=xxyy&MasterRegion=eu-central-1&MaxItems=1337 HTTP/1.1
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/ListLayerVersionsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function testRequest(): void

$expected = '
GET /2018-10-31/layers/demo/versions?CompatibleRuntime=nodejs12.x 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/ListVersionsByFunctionRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function testRequest(): void
// see example-1.json from SDK
$expected = '
GET /2015-03-31/functions/MyFunction/versions?Marker=xxyy&MaxItems=1337 HTTP/1.0
Content-Type: application/json
Content-type: application/json
Accept: application/json
';

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/PublishLayerVersionRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html
$expected = '
POST /2018-10-31/layers/demo/versions HTTP/1.0
Content-Type: application/json
Content-type: application/json
Accept: application/json
{
"Description": "small description",
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Input/UpdateFunctionConfigurationRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function testRequest(): void
// see https://docs.aws.amazon.com/lambda/latest/APIReference/API_UpdateFunctionConfiguration.html
$expected = '
PUT /2015-03-31/functions/test-func/configuration HTTP/1.0
Content-Type: application/json
Content-type: application/json
Accept: application/json
{
"DeadLetterConfig": {
Expand Down

0 comments on commit e26cd9d

Please sign in to comment.