mirror of
https://github.com/apple/swift-nio
synced 2026-11-29 05:24:21 +00:00
Motivation: Currently the HTTPUpgradeHandler does not allow for the protocol upgraders to return EventLoopFuture objects. This leads to an awkward scenario: it's essentially required that an upgrader be able to synchronously change the pipeline to its satisfaction and prepare for more bytes. This is not really possible: ChannelPipeline.add(handler:) returns a Future, which means that it is possible for this operation, at least in principle, to not execute synchronously. This reality puts the HTTPUpgradeHandler at odds with the reality of channel pipelines, and cannot stand. Modifications: Give the HTTPProtocolUpgrader protocol to have upgrade() return an EventLoopFuture<Void>, and update the HTTPServerUpgradeHandler to appropriately handle the returned future by buffering until the future completes. Result: It is no longer necessary to synchronously change the channel pipeline during protocol upgrade.
46 lines
2.0 KiB
Swift
46 lines
2.0 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// HTTPUpgradeTests+XCTest.swift
|
|
//
|
|
import XCTest
|
|
|
|
///
|
|
/// NOTE: This file was generated by generate_linux_tests.rb
|
|
///
|
|
/// Do NOT edit this file directly as it will be regenerated automatically when needed.
|
|
///
|
|
|
|
extension HTTPUpgradeTestCase {
|
|
|
|
static var allTests : [(String, (HTTPUpgradeTestCase) -> () throws -> Void)] {
|
|
return [
|
|
("testUpgradeWithoutUpgrade", testUpgradeWithoutUpgrade),
|
|
("testUpgradeAfterInitialRequest", testUpgradeAfterInitialRequest),
|
|
("testUpgradeHandlerBarfsOnUnexpectedOrdering", testUpgradeHandlerBarfsOnUnexpectedOrdering),
|
|
("testSimpleUpgradeSucceeds", testSimpleUpgradeSucceeds),
|
|
("testUpgradeRequiresCorrectHeaders", testUpgradeRequiresCorrectHeaders),
|
|
("testUpgradeRequiresHeadersInConnection", testUpgradeRequiresHeadersInConnection),
|
|
("testUpgradeOnlyHandlesKnownProtocols", testUpgradeOnlyHandlesKnownProtocols),
|
|
("testUpgradeRespectsClientPreference", testUpgradeRespectsClientPreference),
|
|
("testUpgradeFiresUserEvent", testUpgradeFiresUserEvent),
|
|
("testUpgraderCanRejectUpgradeForPersonalReasons", testUpgraderCanRejectUpgradeForPersonalReasons),
|
|
("testUpgradeIsCaseInsensitive", testUpgradeIsCaseInsensitive),
|
|
("testDelayedUpgradeBehaviour", testDelayedUpgradeBehaviour),
|
|
("testBuffersInboundDataDuringDelayedUpgrade", testBuffersInboundDataDuringDelayedUpgrade),
|
|
]
|
|
}
|
|
}
|
|
|