Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak CI #800

Merged
merged 1 commit into from
Jan 14, 2025
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.library(name: "AsyncHTTPClient", targets: ["AsyncHTTPClient"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.71.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.78.0"),
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.27.1"),
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.19.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.13.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ extension HTTPConnectionPool.ConnectionFactory {

// The proxyEstablishedFuture is set as soon as the HTTP1ProxyConnectHandler is in a
// pipeline. It is created in HTTP1ProxyConnectHandler's handlerAdded method.
return proxyHandler.proxyEstablishedFuture!.flatMap {
channel.pipeline.removeHandler(proxyHandler).flatMap {
channel.pipeline.removeHandler(decoder).flatMap {
channel.pipeline.removeHandler(encoder)
}
}
return proxyHandler.proxyEstablishedFuture!.assumeIsolated().flatMap {
channel.pipeline.syncOperations.removeHandler(proxyHandler).assumeIsolated().flatMap {
channel.pipeline.syncOperations.removeHandler(decoder).assumeIsolated().flatMap {
channel.pipeline.syncOperations.removeHandler(encoder)
}.nonisolated()
}.nonisolated()
}.flatMap {
self.setupTLSInProxyConnectionIfNeeded(channel, deadline: deadline, logger: logger)
}
}.nonisolated()
}
}

Expand Down Expand Up @@ -291,13 +291,13 @@ extension HTTPConnectionPool.ConnectionFactory {

// The socksEstablishedFuture is set as soon as the SOCKSEventsHandler is in a
// pipeline. It is created in SOCKSEventsHandler's handlerAdded method.
return socksEventHandler.socksEstablishedFuture!.flatMap {
channel.pipeline.removeHandler(socksEventHandler).flatMap {
channel.pipeline.removeHandler(socksConnectHandler)
}
return socksEventHandler.socksEstablishedFuture!.assumeIsolated().flatMap {
channel.pipeline.syncOperations.removeHandler(socksEventHandler).assumeIsolated().flatMap {
channel.pipeline.syncOperations.removeHandler(socksConnectHandler)
}.nonisolated()
}.flatMap {
self.setupTLSInProxyConnectionIfNeeded(channel, deadline: deadline, logger: logger)
}
}.nonisolated()
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AsyncHTTPClient/FileDownloadDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
}
} else {
let fileHandleFuture = io.openFile(
path: self.filePath,
_deprecatedPath: self.filePath,
mode: .write,
flags: .allowFileCreation(),
eventLoop: task.eventLoop
Expand Down
4 changes: 3 additions & 1 deletion Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ final class AsyncAwaitEndToEndTests: XCTestCase {
defer { XCTAssertNoThrow(try serverGroup.syncShutdownGracefully()) }
let server = ServerBootstrap(group: serverGroup)
.childChannelInitializer { channel in
channel.pipeline.addHandler(NIOSSLServerHandler(context: sslContext))
channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.addHandler(NIOSSLServerHandler(context: sslContext))
}
}
let serverChannel = try await server.bind(host: "localhost", port: 0).get()
defer { XCTAssertNoThrow(try serverChannel.close().wait()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ extension EmbeddedChannel {
let decoder = try self.pipeline.syncOperations.handler(type: ByteToMessageHandler<HTTPResponseDecoder>.self)
let encoder = try self.pipeline.syncOperations.handler(type: HTTPRequestEncoder.self)

let removeDecoderFuture = self.pipeline.removeHandler(decoder)
let removeEncoderFuture = self.pipeline.removeHandler(encoder)
let removeDecoderFuture = self.pipeline.syncOperations.removeHandler(decoder)
let removeEncoderFuture = self.pipeline.syncOperations.removeHandler(encoder)

self.embeddedEventLoop.run()

Expand Down
10 changes: 5 additions & 5 deletions Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,12 @@ where
try sync.addHandler(requestDecoder)
try sync.addHandler(proxySimulator)

promise.futureResult.flatMap { _ in
channel.pipeline.removeHandler(proxySimulator)
promise.futureResult.assumeIsolated().flatMap { _ in
channel.pipeline.syncOperations.removeHandler(proxySimulator)
}.flatMap { _ in
channel.pipeline.removeHandler(responseEncoder)
channel.pipeline.syncOperations.removeHandler(responseEncoder)
}.flatMap { _ in
channel.pipeline.removeHandler(requestDecoder)
channel.pipeline.syncOperations.removeHandler(requestDecoder)
}.whenComplete { result in
switch result {
case .failure:
Expand Down Expand Up @@ -653,8 +653,8 @@ where
}
}

try channel.pipeline.syncOperations.addHandler(sslHandler)
try channel.pipeline.syncOperations.addHandler(alpnHandler)
try channel.pipeline.syncOperations.addHandler(sslHandler, position: .before(alpnHandler))
}

func shutdown() throws {
Expand Down
8 changes: 6 additions & 2 deletions Tests/AsyncHTTPClientTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,9 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {

let server = ServerBootstrap(group: serverGroup)
.childChannelInitializer { channel in
channel.pipeline.addHandler(NIOSSLServerHandler(context: sslContext))
channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.addHandler(NIOSSLServerHandler(context: sslContext))
}
}
let serverChannel = try server.bind(host: "localhost", port: 0).wait()
defer { XCTAssertNoThrow(try serverChannel.close().wait()) }
Expand Down Expand Up @@ -1642,7 +1644,9 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {

let server = ServerBootstrap(group: serverGroup)
.childChannelInitializer { channel in
channel.pipeline.addHandler(NIOSSLServerHandler(context: sslContext))
channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.addHandler(NIOSSLServerHandler(context: sslContext))
}
}
let serverChannel = try server.bind(host: "localhost", port: 0).wait()
defer { XCTAssertNoThrow(try serverChannel.close().wait()) }
Expand Down
46 changes: 26 additions & 20 deletions Tests/AsyncHTTPClientTests/SOCKSTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ class MockSOCKSServer {
bootstrap = ServerBootstrap(group: elg)
.serverChannelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
.childChannelInitializer { channel in
let handshakeHandler = SOCKSServerHandshakeHandler()
return channel.pipeline.addHandlers([
handshakeHandler,
SOCKSTestHandler(handshakeHandler: handshakeHandler),
TestHTTPServer(
expectedURL: expectedURL,
expectedResponse: expectedResponse,
file: file,
line: line
),
])
channel.eventLoop.makeCompletedFuture {
let handshakeHandler = SOCKSServerHandshakeHandler()
try channel.pipeline.syncOperations.addHandlers([
handshakeHandler,
SOCKSTestHandler(handshakeHandler: handshakeHandler),
TestHTTPServer(
expectedURL: expectedURL,
expectedResponse: expectedResponse,
file: file,
line: line
),
])
}
}
}
self.channel = try bootstrap.bind(host: "localhost", port: 0).wait()
Expand Down Expand Up @@ -112,15 +114,19 @@ class SOCKSTestHandler: ChannelInboundHandler, RemovableChannelHandler {
),
promise: nil
)
context.channel.pipeline.addHandlers(
[
ByteToMessageHandler(HTTPRequestDecoder()),
HTTPResponseEncoder(),
],
position: .after(self)
).whenSuccess {
context.channel.pipeline.removeHandler(self, promise: nil)
context.channel.pipeline.removeHandler(self.handshakeHandler, promise: nil)

do {
try context.channel.pipeline.syncOperations.addHandlers(
[
ByteToMessageHandler(HTTPRequestDecoder()),
HTTPResponseEncoder(),
],
position: .after(self)
)
context.channel.pipeline.syncOperations.removeHandler(self, promise: nil)
context.channel.pipeline.syncOperations.removeHandler(self.handshakeHandler, promise: nil)
} catch {
context.fireErrorCaught(error)
}
}
}
Expand Down
Loading