Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename HTTPHandler to HTTPRequestHandler #85

Merged
merged 1 commit into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/KituraNet/HTTP/HTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> in
if let sslContext = self.sslContext {
_ = channel.pipeline.add(handler: try! OpenSSLServerHandler(context: sslContext), first: true)
Expand Down
8 changes: 4 additions & 4 deletions Sources/KituraNet/HTTP/HTTPServerResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down