From dd7fd7dfef2a4a12047ddb8aa6bf496e4e552325 Mon Sep 17 00:00:00 2001 From: Bryan Moffatt Date: Sat, 30 May 2020 01:13:27 +0100 Subject: [PATCH 1/2] Add a User-Agent when using the Lambda Runtime API --- Sources/AWSLambdaRuntimeCore/HTTPClient.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/AWSLambdaRuntimeCore/HTTPClient.swift b/Sources/AWSLambdaRuntimeCore/HTTPClient.swift index 4945b439..4db5fb10 100644 --- a/Sources/AWSLambdaRuntimeCore/HTTPClient.swift +++ b/Sources/AWSLambdaRuntimeCore/HTTPClient.swift @@ -26,6 +26,7 @@ internal final class HTTPClient { private var state = State.disconnected private var executing = false + private let headers = HTTPHeaders([("User-Agent", "Swift-Lambda/Unknown")]) init(eventLoop: EventLoop, configuration: Lambda.Configuration.RuntimeEngine) { self.eventLoop = eventLoop @@ -37,6 +38,7 @@ internal final class HTTPClient { self.execute(Request(targetHost: self.targetHost, url: url, method: .GET, + headers: headers, timeout: timeout ?? self.configuration.requestTimeout)) } @@ -44,6 +46,7 @@ internal final class HTTPClient { self.execute(Request(targetHost: self.targetHost, url: url, method: .POST, + headers: headers, body: body, timeout: timeout ?? self.configuration.requestTimeout)) } From ac309b1b2140b19b6d8c8288603f1c3a9d379681 Mon Sep 17 00:00:00 2001 From: Bryan Moffatt Date: Sat, 30 May 2020 16:03:57 +0100 Subject: [PATCH 2/2] make it static --- Sources/AWSLambdaRuntimeCore/HTTPClient.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/AWSLambdaRuntimeCore/HTTPClient.swift b/Sources/AWSLambdaRuntimeCore/HTTPClient.swift index 4db5fb10..f3d073d3 100644 --- a/Sources/AWSLambdaRuntimeCore/HTTPClient.swift +++ b/Sources/AWSLambdaRuntimeCore/HTTPClient.swift @@ -26,7 +26,8 @@ internal final class HTTPClient { private var state = State.disconnected private var executing = false - private let headers = HTTPHeaders([("User-Agent", "Swift-Lambda/Unknown")]) + + private static let headers = HTTPHeaders([("user-agent", "Swift-Lambda/Unknown")]) init(eventLoop: EventLoop, configuration: Lambda.Configuration.RuntimeEngine) { self.eventLoop = eventLoop @@ -38,7 +39,7 @@ internal final class HTTPClient { self.execute(Request(targetHost: self.targetHost, url: url, method: .GET, - headers: headers, + headers: HTTPClient.headers, timeout: timeout ?? self.configuration.requestTimeout)) } @@ -46,7 +47,7 @@ internal final class HTTPClient { self.execute(Request(targetHost: self.targetHost, url: url, method: .POST, - headers: headers, + headers: HTTPClient.headers, body: body, timeout: timeout ?? self.configuration.requestTimeout)) }