@@ -248,36 +248,22 @@ internal struct LambdaHTTPServer {
248248 requestHead = head
249249
250250 case . body( let body) :
251- precondition ( requestHead != nil , " Received .body without .head " )
252-
253- // if this is a request from a Streaming Lambda Handler,
254- // stream the response instead of buffering it
255- if self . isStreamingResponse ( requestHead) {
256- // we are receiving a chunked body,
257- // we can stream the response and not accumulate the chunks
258- print ( String ( buffer: body) )
259- } else {
260- requestBody. setOrWriteImmutableBuffer ( body)
261- }
251+ requestBody. setOrWriteImmutableBuffer ( body)
262252
263253 case . end:
264254 precondition ( requestHead != nil , " Received .end without .head " )
265-
266- // process the buffered response for non streaming requests
267- if !self . isStreamingResponse ( requestHead) {
268- // process the complete request
269- let response = try await self . processCompleteRequest (
270- head: requestHead,
271- body: requestBody,
272- logger: logger
273- )
274- // send the responses
275- try await self . sendCompleteResponse (
276- response: response,
277- outbound: outbound,
278- logger: logger
279- )
280- }
255+ // process the request
256+ let response = try await self . processRequest (
257+ head: requestHead,
258+ body: requestBody,
259+ logger: logger
260+ )
261+ // send the responses
262+ try await self . sendResponse (
263+ response: response,
264+ outbound: outbound,
265+ logger: logger
266+ )
281267
282268 requestHead = nil
283269 requestBody = nil
@@ -295,15 +281,6 @@ internal struct LambdaHTTPServer {
295281 }
296282 }
297283
298- /// This function checks if the request is a streaming response request
299- /// verb = POST, uri = :requestID/response, HTTP Header contains "Transfer-Encoding: chunked"
300- private func isStreamingResponse( _ requestHead: HTTPRequestHead ) -> Bool {
301- requestHead. method == . POST &&
302- requestHead. uri. hasSuffix ( Consts . postResponseURLSuffix) &&
303- requestHead. headers. contains ( name: " Transfer-Encoding " ) &&
304- requestHead. headers [ " Transfer-Encoding " ] . contains ( " chunked " )
305- }
306-
307284 /// This function process the URI request sent by the client and by the Lambda function
308285 ///
309286 /// It enqueues the client invocation and iterate over the invocation queue when the Lambda function sends /next request
@@ -314,7 +291,7 @@ internal struct LambdaHTTPServer {
314291 /// - body: the HTTP request body
315292 /// - Throws:
316293 /// - Returns: the response to send back to the client or the Lambda function
317- private func processCompleteRequest (
294+ private func processRequest (
318295 head: HTTPRequestHead ,
319296 body: ByteBuffer ? ,
320297 logger: Logger
@@ -437,7 +414,7 @@ internal struct LambdaHTTPServer {
437414 }
438415 }
439416
440- private func sendCompleteResponse (
417+ private func sendResponse (
441418 response: LocalServerResponse ,
442419 outbound: NIOAsyncChannelOutboundWriter < HTTPServerResponsePart > ,
443420 logger: Logger
0 commit comments