Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/AsyncHTTPClient/FileDownloadDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import NIOPosix

/// Handles a streaming download to a given file path, allowing headers and progress to be reported.
public final class FileDownloadDelegate: HTTPClientResponseDelegate {
/// 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.
/// The response type for this delegate: the response header, the total count of bytes as reported,
/// by the response "Content-Length" header (if available) and the count of bytes downloaded.
public struct Progress: Sendable {
public var responseHead: HTTPResponseHead?
public var totalBytes: Int?
public var receivedBytes: Int
}
Expand Down Expand Up @@ -97,6 +98,7 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
task: HTTPClient.Task<Response>,
_ head: HTTPResponseHead
) -> EventLoopFuture<Void> {
self.progress.responseHead = head
self.reportHead?(head)

if let totalBytesString = head.headers.first(name: "Content-Length"),
Expand Down