Skip to content

Commit

Permalink
Net API update. Dep versions change
Browse files Browse the repository at this point in the history
  • Loading branch information
kjessup committed Jan 24, 2017
1 parent 5117357 commit 13acb7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ let package = Package(
Target(name: "CZlib", dependencies: []),
Target(name: "PerfectHTTPServer", dependencies: ["CHTTPParser", "CZlib"])
],
dependencies: [.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTP.git", majorVersion: 2, minor: 1)],
dependencies: [.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTP.git", majorVersion: 2)],
exclude: ["Sources/CZlib/examples", "Sources/CZlib/test", "Sources/CZlib/contrib"]
)
7 changes: 6 additions & 1 deletion Sources/PerfectHTTPServer/HTTP11Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ class HTTP11Request: HTTPRequest {
}()

var protocolVersion = (1, 0)
var remoteAddress: (host: String, port: UInt16) { return connection.peerName() }
var remoteAddress: (host: String, port: UInt16) {
guard let remote = connection.remoteAddress else {
return ("", 0)
}
return (remote.host, remote.port)
}
var serverAddress = (host: "", port: 0 as UInt16)
var serverName = ""
var documentRoot = "./webroot"
Expand Down
2 changes: 1 addition & 1 deletion Sources/PerfectHTTPServer/HTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public class HTTPServer {
_ = setsockopt(sock.fd.fd, Int32(IPPROTO_TCP), TCP_NODELAY, &flag, UInt32(MemoryLayout<Int32>.size))

defer { sock.close() }
self.serverAddress = sock.sockName().0
self.serverAddress = sock.localAddress?.host ?? ""
sock.forEachAccept {
[weak self] net in
guard let net = net else {
Expand Down

0 comments on commit 13acb7a

Please sign in to comment.