Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 0 additions & 124 deletions Package@swift-6.1.swift

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Please have a look at [SECURITY.md](SECURITY.md) for AsyncHTTPClient's security

## Supported Versions

The most recent versions of AsyncHTTPClient support Swift 6.1 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:
The most recent versions of AsyncHTTPClient support Swift 6.2 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:

AsyncHTTPClient | Minimum Swift Version
--------------------|----------------------
Expand All @@ -320,4 +320,5 @@ AsyncHTTPClient | Minimum Swift Version
`1.26.0 ..< 1.27.0` | 5.9
`1.27.0 ..< 1.30.0` | 5.10
`1.30.0 ..< 1.34.0` | 6.0
`1.34.0 ...` | 6.1
`1.34.0 ..< 1.36.2` | 6.1
`1.37.0 ...` | 6.2
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ struct HTTPRequestStateMachine {
.streaming(let expectedBodyLength, let sentBodyBytes, _),
.receivingBody(let head, let streamState)
):
assert(head.status.code < 300)

if let expected = expectedBodyLength, expected != sentBodyBytes {
let error = HTTPClientError.bodyLengthMismatch
self.state = .failed(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=6.2)
import Configuration
import NIOCore
import NIOHTTP1
Expand Down Expand Up @@ -272,4 +271,3 @@ extension HTTPClient.Authorization {
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct BidirectionalStreamingTests {
}
}

final class HTTPRequestStreamingChannel: ChannelInboundHandler & AHCTestSendableMetatype {
final class HTTPRequestStreamingChannel: ChannelInboundHandler & SendableMetatype {
typealias InboundIn = HTTPServerRequestPart
typealias OutboundOut = HTTPServerResponsePart

Expand Down
8 changes: 1 addition & 7 deletions Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,7 @@ enum TestTLS {
)
}

#if compiler(>=6.2)
typealias AHCTestSendableMetatype = SendableMetatype
#else
typealias AHCTestSendableMetatype = Any
#endif

internal final class HTTPBin<RequestHandler: ChannelInboundHandler & AHCTestSendableMetatype>: Sendable
internal final class HTTPBin<RequestHandler: ChannelInboundHandler & SendableMetatype>: Sendable
where
RequestHandler.InboundIn == HTTPServerRequestPart,
RequestHandler.OutboundOut == HTTPServerResponsePart
Expand Down
36 changes: 36 additions & 0 deletions Tests/AsyncHTTPClientTests/HTTPRequestStateMachineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,42 @@ class HTTPRequestStateMachineTests: XCTestCase {
XCTAssertEqual(state.channelRead(.end(nil)), .forwardResponseEnd(.requestDone, [], nil))
}

func testRequestBodyStreamFinishedAfterServerSentHeadWithStatus413() {
var state = HTTPRequestStateMachine(isChannelWritable: true)
let requestHead = HTTPRequestHead(version: .http1_1, method: .POST, uri: "/")
let metadata = RequestFramingMetadata(connectionClose: false, body: .stream)
XCTAssertEqual(
state.startRequest(head: requestHead, metadata: metadata),
.sendRequestHead(requestHead, sendEnd: false)
)
// Promotes the producer to `.producing`, as the real pipeline does once the head is out.
XCTAssertEqual(
state.headSent(),
.notifyRequestHeadSendSuccessfully(resumeRequestBodyStream: true, startIdleTimer: false)
)

// One part is on the wire and the stream is still open.
let part0 = IOData.byteBuffer(ByteBuffer(bytes: 0...3))
XCTAssertEqual(state.requestStreamPartReceived(part0, promise: nil), .sendBodyPart(part0, nil))

// The server rejects the upload without reading the rest of it. The state machine takes
// this in stride and asks us to pause the body stream.
let responseHead = HTTPResponseHead(version: .http1_1, status: .payloadTooLarge)
XCTAssertEqual(
state.channelRead(.head(responseHead)),
.forwardResponseHead(responseHead, pauseRequestBodyStream: true)
)

// Pausing is not cancelling, so the producer may still finish. This is the trap: the
// action below is the correct one, and the assert crashes before it can be returned.
XCTAssertEqual(
state.requestStreamFinished(trailers: nil, promise: nil),
.sendRequestEnd(trailers: nil, nil, .none)
)

XCTAssertEqual(state.channelRead(.end(nil)), .forwardResponseEnd(.requestDone, [], nil))
}

func testRequestIsFailedIfRequestBodySizeIsWrongEvenAfterServerRespondedWith200() {
var state = HTTPRequestStateMachine(isChannelWritable: true)
let requestHead = HTTPRequestHead(
Expand Down
2 changes: 0 additions & 2 deletions Tests/AsyncHTTPClientTests/SwiftConfigurationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//

#if compiler(>=6.2)
import Configuration
import Foundation
import NIOCore
Expand Down Expand Up @@ -575,4 +574,3 @@ struct HTTPClientConfigurationPropsTests {
}
}
}
#endif
Loading