mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
Motivation: When discardReadBytes() was called and we still did not pass the Head to the user it was quite possible that the headers / URI could be corrupted as the stored readerIndex did not matchup anymore. Modifications: - Override most of the functionality of ByteToMessageDecoder in HTTPDecoder to better work with the provided state machine of http_parser - Remove allocations by removing the pendingInOut Array as its not needed anymore. - Add guards against re-entrance calls - Add unit test that shows that everything works as expected now. Result: Fixed bug and reduced allocations (8% - 10% perf win).
42 lines
1.6 KiB
Swift
42 lines
1.6 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// HTTPDecoderTest+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 HTTPDecoderTest {
|
|
|
|
static var allTests : [(String, (HTTPDecoderTest) -> () throws -> Void)] {
|
|
return [
|
|
("testDoesNotDecodeRealHTTP09Request", testDoesNotDecodeRealHTTP09Request),
|
|
("testDoesNotDecodeFakeHTTP09Request", testDoesNotDecodeFakeHTTP09Request),
|
|
("testDoesNotDecodeHTTP2XRequest", testDoesNotDecodeHTTP2XRequest),
|
|
("testToleratesHTTP13Request", testToleratesHTTP13Request),
|
|
("testDoesNotDecodeRealHTTP09Response", testDoesNotDecodeRealHTTP09Response),
|
|
("testDoesNotDecodeFakeHTTP09Response", testDoesNotDecodeFakeHTTP09Response),
|
|
("testDoesNotDecodeHTTP2XResponse", testDoesNotDecodeHTTP2XResponse),
|
|
("testToleratesHTTP13Response", testToleratesHTTP13Response),
|
|
("testCorrectlyMaintainIndicesWhenDiscardReadBytes", testCorrectlyMaintainIndicesWhenDiscardReadBytes),
|
|
]
|
|
}
|
|
}
|
|
|