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
2 changes: 1 addition & 1 deletion Sources/AsyncHTTPClient/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public class HTTPClient {
/// callback instead of an EventLoopFuture. The reason for that is that NIO's EventLoopFutures will call back on an event loop.
/// The virtue of this function is to shut the event loop down. To work around that we call back on a DispatchQueue
/// instead.
public func shutdown(queue: DispatchQueue, _ callback: @escaping (Error?) -> Void) {
public func shutdown(queue: DispatchQueue = .global(), _ callback: @escaping (Error?) -> Void) {
self.shutdown(requiresCleanClose: false, queue: queue, callback)
}

Expand Down
1 change: 1 addition & 0 deletions Tests/AsyncHTTPClientTests/HTTPClientTests+XCTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ extension HTTPClientTests {
("testRacePoolIdleConnectionsAndGet", testRacePoolIdleConnectionsAndGet),
("testAvoidLeakingTLSHandshakeCompletionPromise", testAvoidLeakingTLSHandshakeCompletionPromise),
("testAsyncShutdown", testAsyncShutdown),
("testAsyncShutdownDefaultQueue", testAsyncShutdownDefaultQueue),
("testValidationErrorsAreSurfaced", testValidationErrorsAreSurfaced),
("testUploadsReallyStream", testUploadsReallyStream),
("testUploadStreamingCallinToleratedFromOtsideEL", testUploadStreamingCallinToleratedFromOtsideEL),
Expand Down
12 changes: 12 additions & 0 deletions Tests/AsyncHTTPClientTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,18 @@ class HTTPClientTests: XCTestCase {
XCTAssertNoThrow(try promise.futureResult.wait())
}

func testAsyncShutdownDefaultQueue() throws {
let localClient = HTTPClient(eventLoopGroupProvider: .shared(self.clientGroup))
let promise = self.clientGroup.next().makePromise(of: Void.self)
self.clientGroup.next().execute {
localClient.shutdown { error in
XCTAssertNil(error)
promise.succeed(())
}
}
XCTAssertNoThrow(try promise.futureResult.wait())
}

func testValidationErrorsAreSurfaced() throws {
let request = try HTTPClient.Request(url: self.defaultHTTPBinURLPrefix + "get", method: .TRACE, body: .stream { _ in
self.defaultClient.eventLoopGroup.next().makeSucceededFuture(())
Expand Down