Skip to content

Commit 2b1cae5

Browse files
committed
use the same if / else logic for .head, .body, and .end
1 parent c3f0340 commit 2b1cae5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Sources/AWSLambdaRuntime/Lambda+LocalServer.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,22 @@ internal struct LambdaHTTPServer {
275275
case .end:
276276
precondition(requestHead != nil, "Received .end without .head")
277277

278-
// process the buffered response for non streaming requests
279-
if !self.isStreamingResponse(requestHead) {
280-
// process the request and send the response
278+
if self.isStreamingResponse(requestHead) {
279+
// for streaming response, send the final response
280+
await self.responsePool.push(
281+
LocalServerResponse(id: requestId, final: true)
282+
)
283+
} else {
284+
// process the buffered response for non streaming requests
281285
try await self.processRequestAndSendResponse(
282286
head: requestHead,
283287
body: requestBody,
284288
outbound: outbound,
285289
logger: logger
286290
)
287-
} else {
288-
await self.responsePool.push(
289-
LocalServerResponse(id: requestId, final: true)
290-
)
291-
292291
}
293292

293+
// reset the request state for next request
294294
requestHead = nil
295295
requestBody = nil
296296
requestId = nil

0 commit comments

Comments
 (0)