mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
Motivation If we receive an early HTTP response, the last action on a HTTP/1.1 connection is to send the .end message. While we had an error handling path in the code, it wasn't tested, and when executed it would end up leaking the connection by failing to close it _or_ return it to the pool. This patch fixes the issue by appropriately terminating the connection and adding a test. Modifications Add a test Terminate the connection if sendEnd fails Result Fewer connection leaks
39 lines
1.7 KiB
Swift
39 lines
1.7 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the AsyncHTTPClient open source project
|
|
//
|
|
// Copyright (c) 2018-2019 Apple Inc. and the AsyncHTTPClient project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// HTTP1ClientChannelHandlerTests+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 HTTP1ClientChannelHandlerTests {
|
|
static var allTests: [(String, (HTTP1ClientChannelHandlerTests) -> () throws -> Void)] {
|
|
return [
|
|
("testResponseBackpressure", testResponseBackpressure),
|
|
("testWriteBackpressure", testWriteBackpressure),
|
|
("testClientHandlerCancelsRequestIfWeWantToShutdown", testClientHandlerCancelsRequestIfWeWantToShutdown),
|
|
("testIdleReadTimeout", testIdleReadTimeout),
|
|
("testIdleReadTimeoutIsCanceledIfRequestIsCanceled", testIdleReadTimeoutIsCanceledIfRequestIsCanceled),
|
|
("testFailHTTPRequestWithContentLengthBecauseOfChannelInactiveWaitingForDemand", testFailHTTPRequestWithContentLengthBecauseOfChannelInactiveWaitingForDemand),
|
|
("testWriteHTTPHeadFails", testWriteHTTPHeadFails),
|
|
("testHandlerClosesChannelIfLastActionIsSendEndAndItFails", testHandlerClosesChannelIfLastActionIsSendEndAndItFails),
|
|
]
|
|
}
|
|
}
|