Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Add data chunk to HTTPProgress when Type == .Download #53

Merged
merged 4 commits into from
Oct 29, 2016
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Docs/QuickStart.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Just.post(
p.type // either .Upload or .Download
p.bytesProcessed
p.bytesExpectedToProcess
p.chunk // present when type == .Download
p.percent
}
) { r in
Expand Down
7 changes: 5 additions & 2 deletions Sources/Just/Just.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public struct HTTPProgress {
public let type: Type
public let bytesProcessed: Int64
public let bytesExpectedToProcess: Int64
public var chunk: Data?
public var percent: Float {
return Float(bytesProcessed) / Float(bytesExpectedToProcess)
}
Expand Down Expand Up @@ -1062,7 +1063,8 @@ extension HTTP: URLSessionTaskDelegate, URLSessionDataDelegate {
HTTPProgress(
type: .upload,
bytesProcessed: totalBytesSent,
bytesExpectedToProcess: totalBytesExpectedToSend
bytesExpectedToProcess: totalBytesExpectedToSend,
chunk: nil
)
)
}
Expand All @@ -1076,7 +1078,8 @@ extension HTTP: URLSessionTaskDelegate, URLSessionDataDelegate {
HTTPProgress(
type: .download,
bytesProcessed: dataTask.countOfBytesReceived,
bytesExpectedToProcess: dataTask.countOfBytesExpectedToReceive
bytesExpectedToProcess: dataTask.countOfBytesExpectedToReceive,
chunk: data
)
)
}
Expand Down