diff --git a/Sources/KituraNet/HTTP/HTTPHandler.swift b/Sources/KituraNet/HTTP/HTTPRequestHandler.swift similarity index 98% rename from Sources/KituraNet/HTTP/HTTPHandler.swift rename to Sources/KituraNet/HTTP/HTTPRequestHandler.swift index 895bfe51..42587632 100644 --- a/Sources/KituraNet/HTTP/HTTPHandler.swift +++ b/Sources/KituraNet/HTTP/HTTPRequestHandler.swift @@ -21,7 +21,7 @@ import LoggerAPI import Foundation import Dispatch -public class HTTPHandler: ChannelInboundHandler { +internal class HTTPRequestHandler: ChannelInboundHandler { /// The HTTPServer instance on which this handler is installed var server: HTTPServer diff --git a/Sources/KituraNet/HTTP/HTTPServer.swift b/Sources/KituraNet/HTTP/HTTPServer.swift index 1b94bf62..533a3348 100644 --- a/Sources/KituraNet/HTTP/HTTPServer.swift +++ b/Sources/KituraNet/HTTP/HTTPServer.swift @@ -133,12 +133,12 @@ public class HTTPServer : Server { .serverChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1) .serverChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEPORT), value: allowPortReuse ? 1 : 0) .childChannelInitializer { channel in - let httpHandler = HTTPHandler(for: self) + let httpHandler = HTTPRequestHandler(for: self) let config: HTTPUpgradeConfiguration = (upgraders: upgraders, completionHandler: { ctx in channelHandlerCtx = ctx _ = channel.pipeline.remove(handler: httpHandler) }) - return channel.pipeline.add(handler: IdleStateHandler(allTimeout: TimeAmount.seconds(Int(HTTPHandler.keepAliveTimeout)))).then { + return channel.pipeline.add(handler: IdleStateHandler(allTimeout: TimeAmount.seconds(Int(HTTPRequestHandler.keepAliveTimeout)))).then { return channel.pipeline.configureHTTPServerPipeline(withServerUpgrade: config, withErrorHandling: true).then { () -> EventLoopFuture in if let sslContext = self.sslContext { _ = channel.pipeline.add(handler: try! OpenSSLServerHandler(context: sslContext), first: true) diff --git a/Sources/KituraNet/HTTP/HTTPServerResponse.swift b/Sources/KituraNet/HTTP/HTTPServerResponse.swift index 8ad2d739..a77543f7 100644 --- a/Sources/KituraNet/HTTP/HTTPServerResponse.swift +++ b/Sources/KituraNet/HTTP/HTTPServerResponse.swift @@ -26,7 +26,7 @@ public class HTTPServerResponse: ServerResponse { private weak var channel: Channel? /// The handler that processed the HTTP request - private weak var handler: HTTPHandler? + private weak var handler: HTTPRequestHandler? /// Status code private var status = HTTPStatusCode.OK.rawValue @@ -54,7 +54,7 @@ public class HTTPServerResponse: ServerResponse { /// The data to be written as a part of the response. private var buffer: ByteBuffer? - init(channel: Channel, handler: HTTPHandler) { + init(channel: Channel, handler: HTTPRequestHandler) { self.channel = channel self.handler = handler let httpVersionMajor = handler.serverRequest?.httpVersionMajor ?? 0 @@ -139,9 +139,9 @@ public class HTTPServerResponse: ServerResponse { if handler.clientRequestedKeepAlive { headers["Connection"] = ["Keep-Alive"] if let maxConnections = handler.keepAliveState.requestsRemaining { - headers["Keep-Alive"] = ["timeout=\(HTTPHandler.keepAliveTimeout), max=\(Int(maxConnections))"] + headers["Keep-Alive"] = ["timeout=\(HTTPRequestHandler.keepAliveTimeout), max=\(Int(maxConnections))"] } else { - headers["Keep-Alive"] = ["timeout=\(HTTPHandler.keepAliveTimeout)"] + headers["Keep-Alive"] = ["timeout=\(HTTPRequestHandler.keepAliveTimeout)"] } } let response = HTTPResponseHead(version: httpVersion, status: status, headers: headers.httpHeaders())