You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -49,19 +49,19 @@ httpClient.get(url: "https://swift.org").whenComplete { result in
49
49
}
50
50
```
51
51
52
-
It is important to close client instanceafter use to cleanly shutdown underlying NIO ```EventLoopGroup```:
53
-
```
52
+
It is important to close the client instance, for example in a `defer` statement, after use to cleanly shutdown the underlying NIO `EventLoopGroup`:
53
+
```swift
54
54
try? httpClient.syncShutdown()
55
55
```
56
-
Alternatively, you can provide shared ```EventLoopGroup```:
56
+
Alternatively, you can provide shared `EventLoopGroup`:
57
57
```swift
58
58
let httpClient =HTTPClient(eventLoopGroupProvider: .shared(userProvidedGroup))
59
59
```
60
60
In this case shutdown of the client is not neccecary.
61
61
62
62
## Usage guide
63
63
64
-
Most common HTTP methods are supported out of the box. In case you need to have more control over the method, or you want to add headers or body, use ```HTTPRequest``` struct:
64
+
Most common HTTP methods are supported out of the box. In case you need to have more control over the method, or you want to add headers or body, use the `HTTPRequest` struct:
65
65
```swift
66
66
importNIOHTTPClient
67
67
@@ -70,7 +70,7 @@ defer {
70
70
try? httpClient.syncShutdown()
71
71
}
72
72
73
-
var request =tryHTTPRequest(url: "https://swift.org", method: .POST)
73
+
var request =tryHTTPClient.HTTPRequest(url: "https://swift.org", method: .POST)
@@ -115,7 +115,7 @@ class CountingDelegate: HTTPResponseDelegate {
115
115
typealiasResponse=Int
116
116
117
117
var count =0
118
-
118
+
119
119
funcdidTransmitRequestBody() {
120
120
// this is executed when request is sent, called once
121
121
}
@@ -130,10 +130,11 @@ class CountingDelegate: HTTPResponseDelegate {
130
130
}
131
131
132
132
funcdidFinishRequest() throws->Int {
133
-
// this is called when request is fully read, called once, this is where you return a result or throw any errors you require to propagate to the client
133
+
// this is called when the request is fully read, called once
134
+
// this is where you return a result or throw any errors you require to propagate to the client
134
135
return count
135
136
}
136
-
137
+
137
138
funcdidReceiveError(_error: Error) {
138
139
// this is called when we receive any network-related error, called once
0 commit comments