Skip to content

Commit

Permalink
#288 #457 Add documentation in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Sep 26, 2019
1 parent a628ebb commit d527461
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Runtime/LambdaRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ public function failInitialization(string $message, ?\Throwable $error = null):
private function postJson(string $url, $data): void
{
$contentType = $data['multiValueHeaders']['content-type'][0] ?? null;
/**
* API Gateway does not support binary content in HTTP responses.
* What we do is:
* - if we are certain the response is not binary (either JSON or the content type starts with `text/*`) we don't encode
* - else we encode all other responses to base64
* API Gateway checks `isBase64Encoded` and decodes what we returned if necessary.
*/
if ($contentType && $contentType !== 'application/json' && substr($contentType, 0, 5) !== 'text/') {
$data['body'] = base64_encode($data['body']);
$data['isBase64Encoded'] = true;
Expand Down

0 comments on commit d527461

Please sign in to comment.