mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: We had a bug which is happens in the combination of these states: - we held a request in the pipelining handler (because we're procesing a previous one) - a http handler error happened whilst a response's `.head` had already been sent (but not yet the `.end`) - the HTTPServerProtocolErrors handler is in use That would lead to this situation: - the error isn't held by the pipelining handler - the error handler then just sends a full response (`.head` and `.end`) but the actual http server already send a `.head`. So all in all, we sent `.head`, `.head`, `.end` which is illegal - the pipelining handler didn't notice this and beause it saw an `.end` it would send through the next requst - now the http server handler is in the situation that it gets `.head`, `.head` too (which is illegal) Modifications: - hold HTTP errors in the pipelining handler too Result: - more correctness
37 lines
1.3 KiB
Swift
37 lines
1.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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// HTTPServerProtocolErrorHandlerTest+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 HTTPServerProtocolErrorHandlerTest {
|
|
|
|
static var allTests : [(String, (HTTPServerProtocolErrorHandlerTest) -> () throws -> Void)] {
|
|
return [
|
|
("testHandlesBasicErrors", testHandlesBasicErrors),
|
|
("testIgnoresNonParserErrors", testIgnoresNonParserErrors),
|
|
("testDoesNotSendAResponseIfResponseHasAlreadyStarted", testDoesNotSendAResponseIfResponseHasAlreadyStarted),
|
|
("testCanHandleErrorsWhenResponseHasStarted", testCanHandleErrorsWhenResponseHasStarted),
|
|
]
|
|
}
|
|
}
|
|
|