@@ -225,6 +225,8 @@ extension HTTPClient {
225
225
public var host : String
226
226
/// Response HTTP status.
227
227
public var status : HTTPResponseStatus
228
+ /// Response HTTP version.
229
+ public var version : HTTPVersion
228
230
/// Reponse HTTP headers.
229
231
public var headers : HTTPHeaders
230
232
/// Response body.
@@ -237,9 +239,27 @@ extension HTTPClient {
237
239
/// - status: Response HTTP status.
238
240
/// - headers: Reponse HTTP headers.
239
241
/// - body: Response body.
242
+ @available ( * , deprecated, renamed: " init(host:status:version:headers:body:) " )
240
243
public init ( host: String , status: HTTPResponseStatus , headers: HTTPHeaders , body: ByteBuffer ? ) {
241
244
self . host = host
242
245
self . status = status
246
+ self . version = HTTPVersion ( major: 1 , minor: 1 )
247
+ self . headers = headers
248
+ self . body = body
249
+ }
250
+
251
+ /// Create HTTP `Response`.
252
+ ///
253
+ /// - parameters:
254
+ /// - host: Remote host of the request.
255
+ /// - status: Response HTTP status.
256
+ /// - version: Response HTTP version.
257
+ /// - headers: Reponse HTTP headers.
258
+ /// - body: Response body.
259
+ public init ( host: String , status: HTTPResponseStatus , version: HTTPVersion , headers: HTTPHeaders , body: ByteBuffer ? ) {
260
+ self . host = host
261
+ self . status = status
262
+ self . version = version
243
263
self . headers = headers
244
264
self . body = body
245
265
}
@@ -342,9 +362,9 @@ public class ResponseAccumulator: HTTPClientResponseDelegate {
342
362
case . idle:
343
363
preconditionFailure ( " no head received before end " )
344
364
case . head( let head) :
345
- return Response ( host: self . request. host, status: head. status, headers: head. headers, body: nil )
365
+ return Response ( host: self . request. host, status: head. status, version : head . version , headers: head. headers, body: nil )
346
366
case . body( let head, let body) :
347
- return Response ( host: self . request. host, status: head. status, headers: head. headers, body: body)
367
+ return Response ( host: self . request. host, status: head. status, version : head . version , headers: head. headers, body: body)
348
368
case . end:
349
369
preconditionFailure ( " request already processed " )
350
370
case . error( let error) :
0 commit comments