Skip to content

Commit

Permalink
Merge pull request #85 from saiHemak/httphandler
Browse files Browse the repository at this point in the history
Rename HTTPHandler to HTTPRequestHandler
  • Loading branch information
Pushkar N Kulkarni authored Sep 5, 2018
2 parents bcc5bc9 + 0d6e1f3 commit 06ff9ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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

0 comments on commit 06ff9ca

Please sign in to comment.