Skip to content

Commit

Permalink
Merge pull request #45 from noppoMan/httpclinet-extend
Browse files Browse the repository at this point in the history
Httpclinet extend
  • Loading branch information
noppoMan authored Apr 20, 2017
2 parents 1c9243f + 2274819 commit aca1ac3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Sources/Prorsum/HTTP/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ public class HTTPClient {
headers: headers,
body: .buffer(body)
)

if let upgradeConnection = upgradeConnection {
request.upgradeConnection(upgradeConnection)
}
return try self.request(request)
}

public func close() {
stream.close()
}

public func request(_ request: Request) throws -> Response {
var request = request
if request.userAgent == nil {
request.userAgent = "Prorsum HTTP Client"
}
Expand All @@ -85,17 +96,13 @@ public class HTTPClient {
}

if request.host == nil {
request.host = url.host
request.host = url.host
}

if request.accept.isEmpty {
request.accept = [try MediaType(string: "Accept: */*")]
}

if let upgradeConnection = upgradeConnection {
request.upgradeConnection(upgradeConnection)
}

let serializer = RequestSerializer(stream: stream)
try serializer.serialize(request, deadline: 0)

Expand Down

0 comments on commit aca1ac3

Please sign in to comment.