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

Commit

Permalink
Merge pull request #53 from divThis/master
Browse files Browse the repository at this point in the history
Add data chunk to HTTPProgress when Type == .Download
  • Loading branch information
dduan authored Oct 29, 2016
2 parents 91902f0 + cd5d749 commit d26b36c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit d26b36c

Please # to comment.