Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dd7fd7d

Browse files
committedMay 30, 2020
Add a User-Agent when using the Lambda Runtime API
1 parent f1ce84f commit dd7fd7d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎Sources/AWSLambdaRuntimeCore/HTTPClient.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ internal final class HTTPClient {
2626

2727
private var state = State.disconnected
2828
private var executing = false
29+
private let headers = HTTPHeaders([("User-Agent", "Swift-Lambda/Unknown")])
2930

3031
init(eventLoop: EventLoop, configuration: Lambda.Configuration.RuntimeEngine) {
3132
self.eventLoop = eventLoop
@@ -37,13 +38,15 @@ internal final class HTTPClient {
3738
self.execute(Request(targetHost: self.targetHost,
3839
url: url,
3940
method: .GET,
41+
headers: headers,
4042
timeout: timeout ?? self.configuration.requestTimeout))
4143
}
4244

4345
func post(url: String, body: ByteBuffer?, timeout: TimeAmount? = nil) -> EventLoopFuture<Response> {
4446
self.execute(Request(targetHost: self.targetHost,
4547
url: url,
4648
method: .POST,
49+
headers: headers,
4750
body: body,
4851
timeout: timeout ?? self.configuration.requestTimeout))
4952
}

0 commit comments

Comments
 (0)
Please sign in to comment.