Skip to content

Commit

Permalink
Merge pull request #113 from pushkarnk/headers-translation
Browse files Browse the repository at this point in the history
Do headers translation only once
  • Loading branch information
Pushkar N Kulkarni authored Nov 22, 2018
2 parents ebdaee3 + 001b4a5 commit c895b61
Showing 1 changed file with 3 additions and 7 deletions.
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 @@ -58,7 +54,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 @@ -120,7 +116,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

0 comments on commit c895b61

Please sign in to comment.