Skip to content

Commit c9d8404

Browse files
committed
Fix case with the string "null" being sent back when using streaming
1 parent d796585 commit c9d8404

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ AWS Lambda Webservices change log
33

44
## ?.?.? / ????-??-??
55

6+
## 1.1.4 / 2023-04-03
7+
8+
* Fixed case with the string "null" being sent back when using streaming
9+
and never writing to the response stream by removing response `body`
10+
(@thekid)
611
* Merged PR #9: Migrate to new testing library - @thekid
712

813
## 1.1.3 / 2022-10-14

src/main/php/com/amazon/aws/lambda/ResponseDocument.class.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Response document
77
*
88
* @test com.amazon.aws.lambda.unittest.ResponseDocumentTest
9+
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
910
*/
1011
class ResponseDocument extends Output {
1112
public $document;
@@ -97,7 +98,10 @@ public function write($bytes) {
9798

9899
/** @return void */
99100
public function finish() {
100-
if (null === $this->document['body']) return;
101+
if (null === $this->document['body']) {
102+
unset($this->document['body']);
103+
return;
104+
}
101105

102106
// Report unencoded length in headers
103107
$this->document['headers']['Content-Length']= (string)strlen($this->document['body']);

src/test/php/com/amazon/aws/lambda/unittest/HttpApiTest.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public function routes($env) {
127127
'statusDescription' => 'Found',
128128
'isBase64Encoded' => false,
129129
'headers' => ['Location' => 'https://example.com', 'Content-Length' => 0],
130-
'body' => null,
131130
],
132131
$this->invoke($fixture->target(), 'GET')
133132
);

src/test/php/com/amazon/aws/lambda/unittest/ResponseDocumentTest.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function no_content() {
2323
'statusDescription' => 'No Content',
2424
'isBase64Encoded' => false,
2525
'headers' => [],
26-
'body' => null,
2726
],
2827
$out->document
2928
);

0 commit comments

Comments
 (0)