mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
Motivation: @pushkarnk hit an interesting edge case that we previously mishandled and crashed. All these conditions need to be true 1. Whilst have an ongoing request (ie. outstanding response), ... 2. ... a `HTTPParserError` arrives (which we correctly queue) 3. Later the outstanding response is completed and then ... 4. ... the `HTTPServerProtocolErrorHandler` sends a .badRequest response We previously crashed. The reason we crashed is that the `HTTPServerPipelineHandler` obviously tracks state and then asserts that no response is sent for a wrong request. It does have an affordance to allow a .badRequest response for a request it couldn't parse. However this state tracking wasn't done if the error itself was enqueued for later delivery. Thanks very much @pushkarnk for the report! Modifications: instead of delivering the error directly use the `deliverOneError` function which transitions the state correctly. Result: fewer crashes & hopefully happy Pushkar
52 lines
3.4 KiB
Swift
52 lines
3.4 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// HTTPServerPipelineHandlerTest+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 HTTPServerPipelineHandlerTest {
|
|
|
|
static var allTests : [(String, (HTTPServerPipelineHandlerTest) -> () throws -> Void)] {
|
|
return [
|
|
("testBasicBufferingBehaviour", testBasicBufferingBehaviour),
|
|
("testReadCallsAreSuppressedWhenPipelining", testReadCallsAreSuppressedWhenPipelining),
|
|
("testReadCallsAreSuppressedWhenUnbufferingIfThereIsStillBufferedData", testReadCallsAreSuppressedWhenUnbufferingIfThereIsStillBufferedData),
|
|
("testServerCanRespondEarly", testServerCanRespondEarly),
|
|
("testPipelineHandlerWillBufferHalfClose", testPipelineHandlerWillBufferHalfClose),
|
|
("testPipelineHandlerWillDeliverHalfCloseEarly", testPipelineHandlerWillDeliverHalfCloseEarly),
|
|
("testAReadIsNotIssuedWhenUnbufferingAHalfCloseAfterRequestComplete", testAReadIsNotIssuedWhenUnbufferingAHalfCloseAfterRequestComplete),
|
|
("testHalfCloseWhileWaitingForResponseIsPassedAlongIfNothingElseBuffered", testHalfCloseWhileWaitingForResponseIsPassedAlongIfNothingElseBuffered),
|
|
("testRecursiveChannelReadInvocationsDoNotCauseIssues", testRecursiveChannelReadInvocationsDoNotCauseIssues),
|
|
("testQuiescingEventWhenInitiallyIdle", testQuiescingEventWhenInitiallyIdle),
|
|
("testQuiescingEventWhenIdleAfterARequest", testQuiescingEventWhenIdleAfterARequest),
|
|
("testQuiescingInTheMiddleOfARequestNoResponseBitsYet", testQuiescingInTheMiddleOfARequestNoResponseBitsYet),
|
|
("testQuiescingAfterHavingReceivedRequestButBeforeResponseWasSent", testQuiescingAfterHavingReceivedRequestButBeforeResponseWasSent),
|
|
("testQuiescingAfterHavingReceivedRequestAndResponseHeadButNoResponseEndYet", testQuiescingAfterHavingReceivedRequestAndResponseHeadButNoResponseEndYet),
|
|
("testQuiescingAfterRequestAndResponseHeadsButBeforeAnyEndsThenRequestEndBeforeResponseEnd", testQuiescingAfterRequestAndResponseHeadsButBeforeAnyEndsThenRequestEndBeforeResponseEnd),
|
|
("testQuiescingAfterRequestAndResponseHeadsButBeforeAnyEndsThenRequestEndAfterResponseEnd", testQuiescingAfterRequestAndResponseHeadsButBeforeAnyEndsThenRequestEndAfterResponseEnd),
|
|
("testQuiescingAfterHavingReceivedOneRequestButBeforeResponseWasSentWithMoreRequestsInTheBuffer", testQuiescingAfterHavingReceivedOneRequestButBeforeResponseWasSentWithMoreRequestsInTheBuffer),
|
|
("testParserErrorOnly", testParserErrorOnly),
|
|
("testLegitRequestFollowedByParserErrorArrivingWhilstResponseOutstanding", testLegitRequestFollowedByParserErrorArrivingWhilstResponseOutstanding),
|
|
]
|
|
}
|
|
}
|
|
|