@@ -24,16 +24,30 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
24
24
public struct Progress : Sendable {
25
25
public var totalBytes : Int ?
26
26
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
+ }
28
46
}
29
47
30
48
private var progress = Progress (
31
49
totalBytes: nil ,
32
- receivedBytes: 0 ,
33
- head: . init(
34
- version: . init( major: 0 , minor: 0 ) ,
35
- status: . init( statusCode: 0 )
36
- )
50
+ receivedBytes: 0
37
51
)
38
52
39
53
public typealias Response = Progress
@@ -142,7 +156,7 @@ public final class FileDownloadDelegate: HTTPClientResponseDelegate {
142
156
task: HTTPClient . Task < Response > ,
143
157
_ head: HTTPResponseHead
144
158
) -> EventLoopFuture < Void > {
145
- self . progress. head = head
159
+ self . progress. _head = head
146
160
147
161
self . reportHead ? ( task, head)
148
162
0 commit comments