Initializerasync-http-client 1.23.0AsyncHTTPClient
init(path:pool:reportHead:reportProgress:)
Initializes a new file download delegate.
FileDownloadDelegate.swift:80convenience init(path: String, pool: NIOThreadPool, reportHead: ((HTTPResponseHead) -> Void)? = nil, reportProgress: ((Progress) -> Void)? = nil) throws
Parameters
- path
Path to a file you’d like to write the download to.
- pool
A thread pool to use for asynchronous file I/O.
- reportHead
A closure called when the response head is available.
- reportProgress
A closure called when a body chunk has been downloaded, with the total byte count and download byte count passed to it as arguments. The callbacks will be invoked in the same threading context that the delegate itself is invoked, as controlled by
EventLoopPreference
.
Other members in extension
Types
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.
Typealiases
Type members
init(path: String, pool: NIOThreadPool?, reportHead: ((HTTPClient.Task<Response>, HTTPResponseHead) -> Void)?, reportProgress: ((HTTPClient.Task<Response>, Progress) -> Void)?
) throws Initializes a new file download delegate.
init(path: String, reportHead: ((HTTPResponseHead) -> Void)?, reportProgress: ((Progress) -> Void)?
) throws Initializes a new file download delegate and uses the shared thread pool of the
HTTPClient
for file I/O.
Instance members
func didFinishRequest(task: HTTPClient.Task<Response>
) throws -> Response func didReceiveBodyPart(task: HTTPClient.Task<Response>, ByteBuffer
) -> EventLoopFuture<Void> func didReceiveError(task: HTTPClient.Task<Progress>, Error
) func didReceiveHead(task: HTTPClient.Task<Response>, HTTPResponseHead
) -> EventLoopFuture<Void>