@@ -126,13 +126,20 @@ class CountingDelegate: HTTPClientResponseDelegate {
126126 // this is executed when request is fully sent, called once
127127 }
128128
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
132136 return task.eventLoop .makeSucceededFuture (())
133137 }
134138
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 > {
136143 // this is executed when we receive parts of the response body, could be called zero or more times
137144 count += buffer.readableBytes
138145 // 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
162169Connecting to servers bound to socket paths is easy:
163170``` swift
164171let 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 (... )
166177```
167178
168179Connecting over TLS to a unix domain socket path is possible as well:
169180``` swift
170181let 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 (... )
172188```
173189
174190Direct URLs can easily be contructed to be executed in other scenarios:
175191``` 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+ )
178200```
0 commit comments