Progress
The response type for this delegate: the total count of bytes as reported by the response “Content-Length” header (if available) and the count of bytes downloaded.
struct Progress
The response type for this delegate: the total count of bytes as reported by the response “Content-Length” header (if available) and the count of bytes downloaded.
struct Progress
import AsyncHTTPClient
This package provides simple HTTP Client library built on top of SwiftNIO.
final class FileDownloadDelegate
Handles a streaming download to a given file path, allowing headers and progress to be reported.
init(path: String, pool: NIOThreadPool? = nil, reportHead: ((HTTPClient.Task<Response>, HTTPResponseHead) -> Void)? = nil, reportProgress: ((HTTPClient.Task<Response>, Progress) -> Void)? = nil) throws
Initializes a new file download delegate.
convenience init(path: String, pool: NIOThreadPool, reportHead: ((HTTPResponseHead) -> Void)? = nil, reportProgress: ((Progress) -> Void)? = nil) throws
Initializes a new file download delegate.
convenience init(path: String, reportHead: ((HTTPResponseHead) -> Void)? = nil, reportProgress: ((Progress) -> Void)? = nil) throws
Initializes a new file download delegate and uses the shared thread pool of the HTTPClient
for file I/O.
func didFinishRequest(task: HTTPClient.Task<Response>) throws -> Response
func didReceiveBodyPart(task: HTTPClient.Task<Response>, _ buffer: ByteBuffer) -> EventLoopFuture<Void>
func didReceiveError(task: HTTPClient.Task<Progress>, _ error: Error)
func didReceiveHead(task: HTTPClient.Task<Response>, _ head: HTTPResponseHead) -> EventLoopFuture<Void>
typealias Response = Progress
protocol Sendable
var receivedBytes: Int
var totalBytes: Int?