@@ -24,16 +24,30 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
2424 public struct Progress : Sendable {
2525 public var totalBytes : Int ?
2626 public var receivedBytes : Int
27- public var head : HTTPResponseHead
27+
28+ public var head : HTTPResponseHead {
29+ get {
30+ #if DEBUG
31+ _head!
32+ #else
33+ _head ?? . init( version: . init( major: 0 , minor: 0 ) , status: . init( statusCode: 0 ) )
34+ #endif
35+ } set {
36+ _head = newValue
37+ }
38+ }
39+
40+ fileprivate var _head : HTTPResponseHead ? = nil
41+
42+ internal init ( totalBytes: Int ? = nil , receivedBytes: Int ) {
43+ self . totalBytes = totalBytes
44+ self . receivedBytes = receivedBytes
45+ }
2846 }
2947
3048 private var progress = Progress (
3149 totalBytes: nil ,
32- receivedBytes: 0 ,
33- head: . init(
34- version: . init( major: 0 , minor: 0 ) ,
35- status: . init( statusCode: 0 )
36- )
50+ receivedBytes: 0
3751 )
3852
3953 public typealias Response = Progress
@@ -142,7 +156,7 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
142156 task: HTTPClient . Task < Response > ,
143157 _ head: HTTPResponseHead
144158 ) -> EventLoopFuture < Void > {
145- self . progress. head = head
159+ self . progress. _head = head
146160
147161 self . reportHead ? ( task, head)
148162
0 commit comments