Skip to content

Commit a13a887

Browse files
committed
feat(lambda): add support for vnd stream responses
1 parent edc2d82 commit a13a887

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/resty/aws/request/execute.lua

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,20 @@ local function execute_request(signed_request)
5050
tostring(err))
5151
end
5252

53+
local body, body_reader
5354

54-
local body do
55-
if response.has_body then
56-
body, err = response:read_body()
57-
if not body then
58-
return nil, ("failed reading response body from '%s:%s': %s"):format(
59-
tostring(signed_request.host),
60-
tostring(signed_request.port),
61-
tostring(err))
55+
if response.headers["application/vnd.amazon.eventstream"] then
56+
body_reader = response.body_reader
57+
else
58+
body do
59+
if response.has_body then
60+
body, err = response:read_body()
61+
if not body then
62+
return nil, ("failed reading response body from '%s:%s': %s"):format(
63+
tostring(signed_request.host),
64+
tostring(signed_request.port),
65+
tostring(err))
66+
end
6267
end
6368
end
6469
end
@@ -82,7 +87,8 @@ local function execute_request(signed_request)
8287
status = response.status,
8388
reason = response.reason,
8489
headers = response.headers,
85-
body = body
90+
body = body,
91+
body_reader = body_reader,
8692
}
8793
end
8894

0 commit comments

Comments
 (0)