mirror of
https://github.com/apple/swift-nio-extras.git
synced 2025-05-16 18:16:04 +08:00
Allow Host in any order
This commit is contained in:
parent
2ba9fbf42d
commit
6da1b1ac32
@ -124,8 +124,10 @@ extension HTTPFields {
|
|||||||
init(_ oldHeaders: HTTPHeaders, splitCookie: Bool) {
|
init(_ oldHeaders: HTTPHeaders, splitCookie: Bool) {
|
||||||
self.init()
|
self.init()
|
||||||
self.reserveCapacity(count)
|
self.reserveCapacity(count)
|
||||||
for (index, field) in oldHeaders.enumerated() {
|
var firstHost = true
|
||||||
if index == 0, field.name.lowercased() == "host" {
|
for field in oldHeaders {
|
||||||
|
if firstHost && field.name.lowercased() == "host" {
|
||||||
|
firstHost = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if let name = HTTPField.Name(field.name) {
|
if let name = HTTPField.Name(field.name) {
|
||||||
@ -175,7 +177,7 @@ extension HTTPRequest {
|
|||||||
init(_ oldRequest: HTTPRequestHead, secure: Bool, splitCookie: Bool) throws {
|
init(_ oldRequest: HTTPRequestHead, secure: Bool, splitCookie: Bool) throws {
|
||||||
let method = try Method(oldRequest.method)
|
let method = try Method(oldRequest.method)
|
||||||
let scheme = secure ? "https" : "http"
|
let scheme = secure ? "https" : "http"
|
||||||
let authority = oldRequest.headers.first.flatMap { $0.name.lowercased() == "host" ? $0.value : nil }
|
let authority = oldRequest.headers["Host"].first
|
||||||
self.init(
|
self.init(
|
||||||
method: method,
|
method: method,
|
||||||
scheme: scheme,
|
scheme: scheme,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user