Skip to content

Commit

Permalink
sockets fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Mar 18, 2017
1 parent 8ee5bfd commit f791f5b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/Routing/Router+Responder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension Router: Responder {

private func supportedMethods(for request: Request) -> [Method] {
let request = request.copy()
guard let host = self.host(for: request.uri.host) else { return [] }
guard let host = self.host(for: request.uri.hostname) else { return [] }
let allOptions = host.allSubBranches
let allPossibleMethods = allOptions.map { Method($0.name) }
return allPossibleMethods.filter { method in
Expand Down
2 changes: 1 addition & 1 deletion Sources/Routing/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Router {

extension Request {
fileprivate func path() -> [String] {
var host: String = uri.host
var host: String = uri.hostname
if host.isEmpty { host = "*" }
let method = self.method.description
let components = uri.path.pathComponents
Expand Down
2 changes: 1 addition & 1 deletion Tests/RoutingTests/RouteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RouteTests: XCTestCase {
let uri = URI(
scheme: "http",
userInfo: nil,
host: "0.0.0.0",
hostname: "0.0.0.0",
port: 80,
path: path.joined(separator: "/"),
query: nil,
Expand Down
4 changes: 2 additions & 2 deletions Tests/RoutingTests/RouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class RouterTests: XCTestCase {

let empties: [String] = ["", "/"]
try empties.forEach { emptypath in
let uri = URI(scheme: "http", host: "0.0.0.0", path: emptypath)
let uri = URI(scheme: "http", hostname: "0.0.0.0", path: emptypath)
let request = Request(method: .get, uri: uri)
let response = try router.respond(to: request)
XCTAssertEqual(response.body.bytes?.makeString(), "Hello, Empty!")
Expand All @@ -155,7 +155,7 @@ class RouterTests: XCTestCase {

let uri = URI(
scheme: "",
host: ""
hostname: ""
)
let request = Request(method: .get, uri: uri)
let response = try router.respond(to: request)
Expand Down
2 changes: 1 addition & 1 deletion Tests/RoutingTests/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import URI

extension Request {
convenience init(method: HTTP.Method, path: String, host: String = "0.0.0.0") {
let uri = URI(host: host, path: path)
let uri = URI(hostname: host, path: path)
self.init(method: method, uri: uri)
}

Expand Down

0 comments on commit f791f5b

Please sign in to comment.