Skip to content

Commit

Permalink
Remove hack to fix issue with AHC backpressure (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored May 19, 2021
1 parent 4a2639f commit c577678
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.16.1")),
.package(url: "https://github.com/apple/swift-nio-ssl.git", .upToNextMajor(from: "2.7.2")),
.package(url: "https://github.com/apple/swift-nio-transport-services.git", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/swift-server/async-http-client.git", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/swift-server/async-http-client.git", .upToNextMajor(from: "1.3.0")),
],
targets: [
.target(name: "SotoCore", dependencies: [
Expand Down
6 changes: 0 additions & 6 deletions Sources/SotoCore/HTTP/AsyncHTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ extension AsyncHTTPClient.HTTPClient: AWSHTTPClient {
deadline: .now() + timeout,
logger: logger
).futureResult
// temporarily wait on delegate response finishing while AHC does not do this for us. See https://github.com/swift-server/async-http-client/issues/274
.flatMap { response in
// if delegate future
guard let futureResult = delegate.bodyPartFuture else { return eventLoop.makeSucceededFuture(response) }
return futureResult.map { return response }
}
} catch {
return eventLoopGroup.next().makeFailedFuture(error)
}
Expand Down
4 changes: 0 additions & 4 deletions Sources/SotoCore/HTTP/ResponseDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class AWSHTTPClientResponseDelegate: HTTPClientResponseDelegate {
let host: String
let stream: (ByteBuffer, EventLoop) -> EventLoopFuture<Void>
var state: State
// temporary stored future while AHC still doesn't sync to futures returned from `didReceiveBodyPart`
// See https://github.com/swift-server/async-http-client/issues/274
var bodyPartFuture: EventLoopFuture<Void>?

init(host: String, stream: @escaping (ByteBuffer, EventLoop) -> EventLoopFuture<Void>) {
self.host = host
Expand Down Expand Up @@ -62,7 +59,6 @@ class AWSHTTPClientResponseDelegate: HTTPClientResponseDelegate {
case .head(let head):
if (200..<300).contains(head.status.code) {
let futureResult = self.stream(part, task.eventLoop)
self.bodyPartFuture = futureResult
return futureResult
}
self.state = .head(head)
Expand Down

0 comments on commit c577678

Please sign in to comment.