diff --git a/Sources/AsyncHTTPClient/HTTPClient.swift b/Sources/AsyncHTTPClient/HTTPClient.swift index 949b09e70..55db26ce2 100644 --- a/Sources/AsyncHTTPClient/HTTPClient.swift +++ b/Sources/AsyncHTTPClient/HTTPClient.swift @@ -215,7 +215,7 @@ public class HTTPClient { let redirectHandler: RedirectHandler? if self.configuration.followRedirects { redirectHandler = RedirectHandler(request: request) { newRequest in - self.execute(request: newRequest, delegate: delegate, deadline: deadline) + self.execute(request: newRequest, delegate: delegate, eventLoop: eventLoop, deadline: deadline) } } else { redirectHandler = nil diff --git a/Tests/AsyncHTTPClientTests/HTTPClientTests.swift b/Tests/AsyncHTTPClientTests/HTTPClientTests.swift index c9b85e957..70a776c4d 100644 --- a/Tests/AsyncHTTPClientTests/HTTPClientTests.swift +++ b/Tests/AsyncHTTPClientTests/HTTPClientTests.swift @@ -487,8 +487,9 @@ class HTTPClientTests: XCTestCase { func testEventLoopArgument() throws { let httpBin = HttpBin() - let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) - let httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup)) + let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 5) + let httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup), + configuration: HTTPClient.Configuration(followRedirects: true)) defer { try! eventLoopGroup.syncShutdownGracefully() httpBin.shutdown() @@ -516,9 +517,13 @@ class HTTPClientTests: XCTestCase { let eventLoop = eventLoopGroup.next() let delegate = EventLoopValidatingDelegate(eventLoop: eventLoop) - let request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)/get") - let response = try httpClient.execute(request: request, delegate: delegate, eventLoop: .prefers(eventLoop)).wait() + var request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)/get") + var response = try httpClient.execute(request: request, delegate: delegate, eventLoop: .prefers(eventLoop)).wait() + XCTAssertEqual(true, response) + // redirect + request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)/redirect/302") + response = try httpClient.execute(request: request, delegate: delegate, eventLoop: .prefers(eventLoop)).wait() XCTAssertEqual(true, response) } }