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

Do headers translation only once #113

Merged
merged 1 commit into from
Nov 22, 2018
Merged
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
10 changes: 3 additions & 7 deletions Sources/KituraNet/HTTP/HTTPServerRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ import Foundation
public class HTTPServerRequest: ServerRequest {

/// Set of HTTP headers of the request.
public var headers : HeadersContainer {
return HeadersContainer.create(from: _headers)
}

private var _headers: HTTPHeaders
public var headers : HeadersContainer

@available(*, deprecated, message: "This contains just the path and query parameters starting with '/'. use 'urlURL' instead")
public var urlString : String {
Expand Down Expand Up @@ -60,7 +56,7 @@ public class HTTPServerRequest: ServerRequest {

self.enableSSL ? url.append("https://") : url.append("http://")

if let hostname = _headers["Host"].first {
if let hostname = headers["Host"]?.first {
url.append(hostname)
if !hostname.contains(":") {
url.append(":")
Expand Down Expand Up @@ -122,7 +118,7 @@ public class HTTPServerRequest: ServerRequest {
}

init(ctx: ChannelHandlerContext, requestHead: HTTPRequestHead, enableSSL: Bool) {
self._headers = requestHead.headers
self.headers = HeadersContainer.create(from: requestHead.headers)
self.method = String(describing: requestHead.method)
self.httpVersionMajor = requestHead.version.major
self.httpVersionMinor = requestHead.version.minor
Expand Down