Skip to content

Commit eaa6fb6

Browse files
authored
Add a User-Agent when using the Lambda Runtime API (#98)
* Add a User-Agent when using the Lambda Runtime API
1 parent f1ce84f commit eaa6fb6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: Sources/AWSLambdaRuntimeCore/HTTPClient.swift

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ internal final class HTTPClient {
2727
private var state = State.disconnected
2828
private var executing = false
2929

30+
private static let headers = HTTPHeaders([("user-agent", "Swift-Lambda/Unknown")])
31+
3032
init(eventLoop: EventLoop, configuration: Lambda.Configuration.RuntimeEngine) {
3133
self.eventLoop = eventLoop
3234
self.configuration = configuration
@@ -37,13 +39,15 @@ internal final class HTTPClient {
3739
self.execute(Request(targetHost: self.targetHost,
3840
url: url,
3941
method: .GET,
42+
headers: HTTPClient.headers,
4043
timeout: timeout ?? self.configuration.requestTimeout))
4144
}
4245

4346
func post(url: String, body: ByteBuffer?, timeout: TimeAmount? = nil) -> EventLoopFuture<Response> {
4447
self.execute(Request(targetHost: self.targetHost,
4548
url: url,
4649
method: .POST,
50+
headers: HTTPClient.headers,
4751
body: body,
4852
timeout: timeout ?? self.configuration.requestTimeout))
4953
}

0 commit comments

Comments
 (0)