Files
swift-nio/Tests/NIOHTTP1Tests/HTTPUpgradeTests+XCTest.swift
T
Norman Maurer 398b950eee Ensure HTTPDecoder will not run into re-entrance issues and correctly forward bytes left after removal. (#427)
Motivation:

We need to ensure we correctly guard against re-entrancy for all cases. Also we did not correctly ensure we forward pending data after removal which could lead to missing data after upgrades.

Modifications:

- pause the parser when we need to callout to the pipeline and so ensure we never fire events throught the pipeline while in callbacks of http_parser
- correctly forward any pending bytes if an upgrade happened when the decoder is removed
- Ensure HTTPUpgradeHandler only remove decoder after the full request is received
- Add testcase provided by @weissi

Result:

Correctly handle upgrades and pending data. Fixes https://github.com/apple/swift-nio/issues/422.
2018-05-23 12:38:53 +01:00

49 lines
2.3 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),
("testRemovesAllHTTPRelatedHandlersAfterUpgrade", testRemovesAllHTTPRelatedHandlersAfterUpgrade),
("testBasicUpgradePipelineMutation", testBasicUpgradePipelineMutation),
("testUpgradeWithUpgradePayloadInlineWithRequestWorks", testUpgradeWithUpgradePayloadInlineWithRequestWorks),
]
}
}