@@ -126,13 +126,20 @@ class CountingDelegate: HTTPClientResponseDelegate {
126
126
// this is executed when request is fully sent, called once
127
127
}
128
128
129
- func didReceiveHead (task : HTTPClient.Task<Response>, _ head : HTTPResponseHead) -> EventLoopFuture<Void > {
130
- // this is executed when we receive HTTP response head part of the request (it contains response code and headers), called once
131
- // in case backpressure is needed, all reads will be paused until returned future is resolved
129
+ func didReceiveHead (
130
+ task : HTTPClient.Task<Response>,
131
+ _ head : HTTPResponseHead
132
+ ) -> EventLoopFuture<Void > {
133
+ // this is executed when we receive HTTP response head part of the request
134
+ // (it contains response code and headers), called once in case backpressure
135
+ // is needed, all reads will be paused until returned future is resolved
132
136
return task.eventLoop .makeSucceededFuture (())
133
137
}
134
138
135
- func didReceiveBodyPart (task : HTTPClient.Task<Response>, _ buffer : ByteBuffer) -> EventLoopFuture<Void > {
139
+ func didReceiveBodyPart (
140
+ task : HTTPClient.Task<Response>,
141
+ _ buffer : ByteBuffer
142
+ ) -> EventLoopFuture<Void > {
136
143
// this is executed when we receive parts of the response body, could be called zero or more times
137
144
count += buffer.readableBytes
138
145
// in case backpressure is needed, all reads will be paused until returned future is resolved
@@ -162,17 +169,32 @@ httpClient.execute(request: request, delegate: delegate).futureResult.whenSucces
162
169
Connecting to servers bound to socket paths is easy:
163
170
``` swift
164
171
let httpClient = HTTPClient (eventLoopGroupProvider : .createNew )
165
- httpClient.execute (.GET , socketPath : " /tmp/myServer.socket" , urlPath : " /path/to/resource" ).whenComplete (... )
172
+ httpClient.execute (
173
+ .GET ,
174
+ socketPath : " /tmp/myServer.socket" ,
175
+ urlPath : " /path/to/resource"
176
+ ).whenComplete (... )
166
177
```
167
178
168
179
Connecting over TLS to a unix domain socket path is possible as well:
169
180
``` swift
170
181
let httpClient = HTTPClient (eventLoopGroupProvider : .createNew )
171
- httpClient.execute (.POST , secureSocketPath : " /tmp/myServer.socket" , urlPath : " /path/to/resource" , body : .string (" hello" )).whenComplete (... )
182
+ httpClient.execute (
183
+ .POST ,
184
+ secureSocketPath : " /tmp/myServer.socket" ,
185
+ urlPath : " /path/to/resource" ,
186
+ body : .string (" hello" )
187
+ ).whenComplete (... )
172
188
```
173
189
174
190
Direct URLs can easily be contructed to be executed in other scenarios:
175
191
``` swift
176
- let socketPathBasedURL = URL (httpURLWithSocketPath : " /tmp/myServer.socket" , uri : " /path/to/resource" )
177
- let secureSocketPathBasedURL = URL (httpsURLWithSocketPath : " /tmp/myServer.socket" , uri : " /path/to/resource" )
192
+ let socketPathBasedURL = URL (
193
+ httpURLWithSocketPath : " /tmp/myServer.socket" ,
194
+ uri : " /path/to/resource"
195
+ )
196
+ let secureSocketPathBasedURL = URL (
197
+ httpsURLWithSocketPath : " /tmp/myServer.socket" ,
198
+ uri : " /path/to/resource"
199
+ )
178
200
```
0 commit comments