//===----------------------------------------------------------------------===// // // This source file is part of the AsyncHTTPClient open source project // // Copyright (c) 2018-2019 Apple Inc. and the AsyncHTTPClient project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information // See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors // // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// import NIO import NIOHTTP1 public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate { public typealias Response = Void let chunkHandler: (ByteBuffer) -> EventLoopFuture init(chunkHandler: @escaping (ByteBuffer) -> EventLoopFuture) { self.chunkHandler = chunkHandler } public func didReceiveBodyPart(task: HTTPClient.Task, _ buffer: ByteBuffer) -> EventLoopFuture { return self.chunkHandler(buffer) } public func didFinishRequest(task: HTTPClient.Task) throws { return () } }