Skip to content

Commit ea0f0d3

Browse files
committed
Fix headers comment, fix transfer-encoding value of streamingHeaders, update env var missing error name
1 parent aed1a8e commit ea0f0d3

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Sources/AWSLambdaRuntimeCore/NewLambdaRuntime.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ package final class NewLambdaRuntime<Handler>: Sendable where Handler: Streaming
3535

3636
package func run() async throws {
3737
guard let runtimeEndpoint = Lambda.env("AWS_LAMBDA_RUNTIME_API") else {
38-
throw NewLambdaRuntimeError(code: .cannotStartLambdaRuntime)
38+
throw NewLambdaRuntimeError(code: .missingLambdaRuntimeAPIEnvironmentVariable)
3939
}
4040

4141
let ipAndPort = runtimeEndpoint.split(separator: ":", maxSplits: 1)

Sources/AWSLambdaRuntimeCore/NewLambdaRuntimeClient.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,11 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
435435
private let delegate: Delegate
436436
private let configuration: NewLambdaRuntimeClient.Configuration
437437

438+
/// These are the default headers that must be sent along an invocation
438439
let defaultHeaders: HTTPHeaders
439440
/// These headers must be sent along an invocation or initialization error report
440441
let errorHeaders: HTTPHeaders
441-
/// These headers must be sent along an invocation or initialization error report
442+
/// These headers must be sent when streaming a response
442443
let streamingHeaders: HTTPHeaders
443444

444445
init(delegate: Delegate, logger: Logger, configuration: NewLambdaRuntimeClient.Configuration) {
@@ -457,7 +458,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
457458
self.streamingHeaders = [
458459
"host": "\(self.configuration.ip):\(self.configuration.port)",
459460
"user-agent": "Swift-Lambda/Unknown",
460-
"transfer-encoding": "streaming",
461+
"transfer-encoding": "chunked",
461462
]
462463
}
463464

Sources/AWSLambdaRuntimeCore/NewLambdaRuntimeError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ package struct NewLambdaRuntimeError: Error {
2929
case nextInvocationMissingHeaderDeadline
3030
case nextInvocationMissingHeaderInvokeFuctionARN
3131

32-
case cannotStartLambdaRuntime
32+
case missingLambdaRuntimeAPIEnvironmentVariable
3333
case runtimeCanOnlyBeStartedOnce
3434
case invalidPort
3535
}

0 commit comments

Comments
 (0)