Skip to content

Commit 75a2e40

Browse files
committed
fix(ios): patch download progress to handle X-Uncompressed-Content-Length
1 parent 7e7a305 commit 75a2e40

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ios/patches/Alamofire+5.9.1.diff

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
diff --git a/Pods/Alamofire/Source/Core/SessionDelegate.swift b/Pods/Alamofire/Source/Core/SessionDelegate.swift
2-
index de0fcbb..5ebacfa 100644
2+
index 1d120e6..fe8f5b9 100644
33
--- a/Pods/Alamofire/Source/Core/SessionDelegate.swift
44
+++ b/Pods/Alamofire/Source/Core/SessionDelegate.swift
5-
@@ -343,8 +343,15 @@ extension SessionDelegate: URLSessionDownloadDelegate {
5+
@@ -343,6 +343,15 @@ extension SessionDelegate: URLSessionDownloadDelegate {
66
return
77
}
88

9-
- downloadRequest.updateDownloadProgress(bytesWritten: bytesWritten,
10-
+ let sizeString = ((downloadTask.response as? HTTPURLResponse)?.allHeaderFields["X-Uncompressed-Content-Length"]) as? String
9+
+ let allHeaders = (downloadRequest.response)?.allHeaderFields as? NSDictionary ?? NSDictionary()
10+
+ let sizeString = (allHeaders["X-Uncompressed-Content-Length"] ?? allHeaders["x-uncompressed-content-length"]) as? String
1111
+ if (sizeString != nil) {
1212
+ let size = Int64(sizeString!)
1313
+ downloadRequest.updateDownloadProgress(bytesWritten: bytesWritten,
14-
totalBytesExpectedToWrite: totalBytesExpectedToWrite)
15-
+ } else {
16-
+ downloadRequest.updateDownloadProgress(bytesWritten: bytesWritten,
17-
+ totalBytesExpectedToWrite: totalBytesExpectedToWrite)
14+
+ totalBytesExpectedToWrite: size!)
15+
+ return
1816
+ }
17+
+
18+
downloadRequest.updateDownloadProgress(bytesWritten: bytesWritten,
19+
totalBytesExpectedToWrite: totalBytesExpectedToWrite)
1920
}
20-
21-
open func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {

0 commit comments

Comments
 (0)