Skip to content

Commit

Permalink
ZincURLSession
Browse files Browse the repository at this point in the history
Simulating NSURLSession
  • Loading branch information
Andy Mroczkowski committed Dec 13, 2013
1 parent 609c3ca commit 8436676
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 105 deletions.
30 changes: 30 additions & 0 deletions Zinc-ObjC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
B3125CFD185A5ED400CB6A7A /* ZincEventHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125CFA185A5ED400CB6A7A /* ZincEventHelpers.h */; };
B3125CFE185A5ED400CB6A7A /* ZincEventHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = B3125CFB185A5ED400CB6A7A /* ZincEventHelpers.m */; };
B3125CFF185A5ED400CB6A7A /* ZincEventHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = B3125CFB185A5ED400CB6A7A /* ZincEventHelpers.m */; };
B3125D01185A87CA00CB6A7A /* ZincURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125D00185A87CA00CB6A7A /* ZincURLSession.h */; };
B3125D02185A87CA00CB6A7A /* ZincURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125D00185A87CA00CB6A7A /* ZincURLSession.h */; };
B3125D05185A8A0900CB6A7A /* ZincURLSessionImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125D03185A8A0900CB6A7A /* ZincURLSessionImpl.h */; };
B3125D06185A8A0900CB6A7A /* ZincURLSessionImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125D03185A8A0900CB6A7A /* ZincURLSessionImpl.h */; };
B3125D07185A8A0900CB6A7A /* ZincURLSessionImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = B3125D04185A8A0900CB6A7A /* ZincURLSessionImpl.m */; };
B3125D08185A8A0900CB6A7A /* ZincURLSessionImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = B3125D04185A8A0900CB6A7A /* ZincURLSessionImpl.m */; };
B3125D0B185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125D09185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h */; };
B3125D0C185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B3125D09185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h */; };
B3125D0D185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m in Sources */ = {isa = PBXBuildFile; fileRef = B3125D0A185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m */; };
B3125D0E185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m in Sources */ = {isa = PBXBuildFile; fileRef = B3125D0A185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m */; };
B313BF9417E8E27500B69E7D /* NSOperationZincSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = B313BF9317E8E27500B69E7D /* NSOperationZincSpec.m */; };
B313BF9F17E8E9D700B69E7D /* ZincChildren.h in Headers */ = {isa = PBXBuildFile; fileRef = B3E039B817E8C6CA00575189 /* ZincChildren.h */; settings = {ATTRIBUTES = (Public, ); }; };
B317E4F215C9F8AF00DE9D73 /* ZincJSONSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = B317E4F015C9F8AF00DE9D73 /* ZincJSONSerialization.m */; };
Expand Down Expand Up @@ -419,6 +429,11 @@
B3125CF7185A4EE500CB6A7A /* ZincHTTPRequestOperationFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZincHTTPRequestOperationFactory.m; sourceTree = "<group>"; };
B3125CFA185A5ED400CB6A7A /* ZincEventHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZincEventHelpers.h; sourceTree = "<group>"; };
B3125CFB185A5ED400CB6A7A /* ZincEventHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZincEventHelpers.m; sourceTree = "<group>"; };
B3125D00185A87CA00CB6A7A /* ZincURLSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZincURLSession.h; sourceTree = "<group>"; };
B3125D03185A8A0900CB6A7A /* ZincURLSessionImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZincURLSessionImpl.h; sourceTree = "<group>"; };
B3125D04185A8A0900CB6A7A /* ZincURLSessionImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZincURLSessionImpl.m; sourceTree = "<group>"; };
B3125D09185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ZincHTTPURLConnectionOperation+ZincURLSessionTask.h"; sourceTree = "<group>"; };
B3125D0A185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ZincHTTPURLConnectionOperation+ZincURLSessionTask.m"; sourceTree = "<group>"; };
B313BF9317E8E27500B69E7D /* NSOperationZincSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSOperationZincSpec.m; sourceTree = "<group>"; };
B317E4EF15C9F8AF00DE9D73 /* ZincJSONSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZincJSONSerialization.h; sourceTree = "<group>"; };
B317E4F015C9F8AF00DE9D73 /* ZincJSONSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZincJSONSerialization.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -764,10 +779,14 @@
B3125CF4185A4B9000CB6A7A /* NSURLConnection */ = {
isa = PBXGroup;
children = (
B3125D03185A8A0900CB6A7A /* ZincURLSessionImpl.h */,
B3125D04185A8A0900CB6A7A /* ZincURLSessionImpl.m */,
B3F201E517722C8E00F4A01E /* ZincURLConnectionOperation.h */,
B3F201E617722C8E00F4A01E /* ZincURLConnectionOperation.m */,
B3F201E117722C4600F4A01E /* ZincHTTPURLConnectionOperation.h */,
B3F201E217722C4600F4A01E /* ZincHTTPURLConnectionOperation.m */,
B3125D09185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h */,
B3125D0A185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m */,
);
name = NSURLConnection;
sourceTree = "<group>";
Expand Down Expand Up @@ -1301,6 +1320,7 @@
B3F201E917722C9700F4A01E /* Networking */ = {
isa = PBXGroup;
children = (
B3125D00185A87CA00CB6A7A /* ZincURLSession.h */,
B3125CF6185A4EE500CB6A7A /* ZincHTTPRequestOperationFactory.h */,
B3125CF7185A4EE500CB6A7A /* ZincHTTPRequestOperationFactory.m */,
B3125CF5185A4DC900CB6A7A /* ZincHTTPRequestOperation.h */,
Expand All @@ -1318,6 +1338,7 @@
files = (
B31DE3A516CCBACA004F88ED /* Zinc.h in Headers */,
B31DE3A616CCBACA004F88ED /* ZincGlobals.h in Headers */,
B3125D0B185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h in Headers */,
B31DE3A716CCBACA004F88ED /* ZincErrors.h in Headers */,
B31DE3A816CCBACA004F88ED /* ZincRepo.h in Headers */,
B3F201E717722C8E00F4A01E /* ZincURLConnectionOperation.h in Headers */,
Expand All @@ -1328,6 +1349,7 @@
B31DE3AA16CCBACA004F88ED /* ZincResource.h in Headers */,
B31DE3AB16CCBACA004F88ED /* ZincBundleTrackingRequest.h in Headers */,
B31DE3AC16CCBACA004F88ED /* ZincEvent.h in Headers */,
B3125D05185A8A0900CB6A7A /* ZincURLSessionImpl.h in Headers */,
B31DE3AD16CCBACA004F88ED /* ZincTaskRef.h in Headers */,
B3D4CE7E184D47B5002015AA /* UIImage+Zinc.h in Headers */,
B3D4CEA8184D4866002015AA /* ZincBundleListViewCell.h in Headers */,
Expand All @@ -1345,6 +1367,7 @@
B3A960E317A8892E0031466A /* ZincAgent.h in Headers */,
B31DE3B616CCBACA004F88ED /* ZincOperation.h in Headers */,
B3D4CE80184D47D7002015AA /* ZincAdminViewController.h in Headers */,
B3125D01185A87CA00CB6A7A /* ZincURLSession.h in Headers */,
B3466BD8171DB9C100021D84 /* ZincDownloadPolicy+Private.h in Headers */,
B3D4CEAA184D4866002015AA /* ZincBundleListViewController.h in Headers */,
B3D4CEA4184D4866002015AA /* ZincBundleDetailCell.h in Headers */,
Expand Down Expand Up @@ -1378,6 +1401,7 @@
B36388F617E1863400F2BBE4 /* ZincRepo.h in Headers */,
B36388F717E1863400F2BBE4 /* ZincURLConnectionOperation.h in Headers */,
B36388F817E1863400F2BBE4 /* ZincBundle.h in Headers */,
B3125D06185A8A0900CB6A7A /* ZincURLSessionImpl.h in Headers */,
B36388F917E1863400F2BBE4 /* ZincResource.h in Headers */,
B36388FA17E1863400F2BBE4 /* ZincBundleTrackingRequest.h in Headers */,
B36388FB17E1863400F2BBE4 /* ZincEvent.h in Headers */,
Expand All @@ -1389,9 +1413,11 @@
B363890117E1863400F2BBE4 /* ZincRepoMonitor.h in Headers */,
B363890217E1863400F2BBE4 /* ZincBundleAvailabilityMonitor.h in Headers */,
B363890417E1863400F2BBE4 /* ZincUtils.h in Headers */,
B3125D02185A87CA00CB6A7A /* ZincURLSession.h in Headers */,
B3125CFD185A5ED400CB6A7A /* ZincEventHelpers.h in Headers */,
B363890517E1863400F2BBE4 /* ZincTask.h in Headers */,
B363890617E1863400F2BBE4 /* ZincAgent.h in Headers */,
B3125D0C185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.h in Headers */,
B363890717E1863400F2BBE4 /* ZincOperation.h in Headers */,
B363890917E1863400F2BBE4 /* ZincDownloadPolicy+Private.h in Headers */,
B363890A17E1863400F2BBE4 /* NSOperation+Zinc.h in Headers */,
Expand Down Expand Up @@ -1879,6 +1905,7 @@
B327071F14BCE758004E3244 /* ZincObjectDownloadTask.m in Sources */,
B3EACD8714BD4907004D90EC /* ZincGarbageCollectTask.m in Sources */,
B3CEEC0314BE0F270023DF5B /* ZincBundleDeleteTask.m in Sources */,
B3125D0D185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m in Sources */,
B3215E2314BE5AF800FC7FA7 /* ZincTaskDescriptor.m in Sources */,
B3215E2714BE600E00FC7FA7 /* ZincResource.m in Sources */,
B3215E2B14BE7E3C00FC7FA7 /* ZincCatalogUpdateTask.m in Sources */,
Expand All @@ -1894,6 +1921,7 @@
B3125CFE185A5ED400CB6A7A /* ZincEventHelpers.m in Sources */,
B338E50914CE0FBC00BC0915 /* ZincGlobals.m in Sources */,
B3D4CE83184D480F002015AA /* UIImage+Zinc.m in Sources */,
B3125D07185A8A0900CB6A7A /* ZincURLSessionImpl.m in Sources */,
B3D4CEA5184D4866002015AA /* ZincBundleDetailCell.m in Sources */,
B3BE1CDA14D79ECA00C61515 /* ZincDownloadTask.m in Sources */,
B396E30D1590FB8D00584F83 /* ZincBundleCloneTask.m in Sources */,
Expand Down Expand Up @@ -1990,6 +2018,7 @@
B36388BC17E1863400F2BBE4 /* ZincBundleRemoteCloneTask.m in Sources */,
B36388BD17E1863400F2BBE4 /* ZincTask.m in Sources */,
B36388BE17E1863400F2BBE4 /* ZincSourceUpdateTask.m in Sources */,
B3125D0E185A92E500CB6A7A /* ZincHTTPURLConnectionOperation+ZincURLSessionTask.m in Sources */,
B36388BF17E1863400F2BBE4 /* ZincManifestDownloadTask.m in Sources */,
B36388C017E1863400F2BBE4 /* ZincObjectDownloadTask.m in Sources */,
B36388C117E1863400F2BBE4 /* ZincGarbageCollectTask.m in Sources */,
Expand All @@ -2012,6 +2041,7 @@
B36388D217E1863400F2BBE4 /* ZincOperation.m in Sources */,
B36388D317E1863400F2BBE4 /* ZincTaskRef.m in Sources */,
B36388D417E1863400F2BBE4 /* ZincHTTPURLConnectionOperation.m in Sources */,
B3125D08185A8A0900CB6A7A /* ZincURLSessionImpl.m in Sources */,
B36388D517E1863400F2BBE4 /* ZincJSONSerialization.m in Sources */,
B36388D617E1863400F2BBE4 /* ZincDownloadPolicy.m in Sources */,
B36388D717E1863400F2BBE4 /* NSError+Zinc.m in Sources */,
Expand Down
9 changes: 6 additions & 3 deletions Zinc/Private/ZincArchiveDownloadTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "ZincDownloadTask+Private.h"
#import "ZincRepo+Private.h"
#import "ZincEventHelpers.h"
#import "ZincURLSession.h"

@interface ZincArchiveDownloadTask ()
@property (nonatomic, strong) ZincArchiveExtractOperation* extractOp;
Expand Down Expand Up @@ -78,11 +79,13 @@ - (void) main
NSURLRequest* request = [source urlRequestForArchivedBundleName:bundleName version:self.version flavor:flavor];
[self queueOperationForRequest:request downloadPath:self.downloadPath context:self.bundleID];

[self.httpRequestOperation waitUntilFinished];
[self.URLSessionTask waitUntilFinished];
if (self.isCancelled) return;

NSDictionary* eventAttrs = [ZincEventHelpers attributesForRequest:self.URLSessionTask.originalRequest andResponse:self.URLSessionTask.response];

if (!self.httpRequestOperation.hasAcceptableStatusCode) {
[self addEvent:[ZincErrorEvent eventWithError:self.httpRequestOperation.error source:ZINC_EVENT_SRC() attributes:[ZincEventHelpers attributesForRequestOperation:self.httpRequestOperation]]];
if (self.URLSessionTask.error != nil) {
[self addEvent:[ZincErrorEvent eventWithError:self.URLSessionTask.error source:ZINC_EVENT_SRC() attributes:eventAttrs]];
continue;
} else {
[self addEvent:[ZincDownloadCompleteEvent downloadCompleteEventForURL:request.URL size:self.bytesRead]];
Expand Down
7 changes: 2 additions & 5 deletions Zinc/Private/ZincDownloadTask+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@

#import "ZincDownloadTask.h"

@protocol ZincHTTPRequestOperation;
@protocol ZincURLSessionTask;

@interface ZincDownloadTask ()

@property (readwrite) long long bytesRead;
@property (readwrite) long long totalBytesToRead;

@property (nonatomic, strong, readwrite) id<ZincHTTPRequestOperation> httpRequestOperation;
@property (nonatomic, strong, readwrite) id<ZincURLSessionTask> URLSessionTask;

- (void) queueOperationForRequest:(NSURLRequest *)request
downloadPath:(NSString *)downloadPath
Expand Down
1 change: 0 additions & 1 deletion Zinc/Private/ZincDownloadTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
@interface ZincDownloadTask : ZincTask

@property (readonly) long long bytesRead;
@property (readonly) long long totalBytesToRead;

@end
61 changes: 10 additions & 51 deletions Zinc/Private/ZincDownloadTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,29 @@

@interface ZincDownloadTask()
@property (nonatomic, strong, readwrite) id context;
@property (atomic, readwrite) BOOL trackingProgress;
@end

@implementation ZincDownloadTask


+ (NSString *)action
{
return ZincTaskActionUpdate;
}

- (void) queueOperationForRequest:(NSURLRequest *)request downloadPath:(NSString *)downloadPath context:(id)context
{
NSAssert(self.httpRequestOperation == nil || [self.httpRequestOperation isFinished], @"operation already enqueued");

id<ZincHTTPRequestOperation> requestOp = [self.repo.requestOperationFactory operationForRequest:request];
NSAssert(self.URLSessionTask == nil || [self.URLSessionTask isFinished], @"URLSessionTask already enqueued");

if (downloadPath != nil) {
requestOp.outputStream = [[NSOutputStream alloc] initToFileAtPath:downloadPath append:NO];
}
id<ZincURLSessionTask> requestTask = [self.repo.URLSession downloadTaskWithRequest:request destinationPath:downloadPath completionHandler:nil];

self.context = context;

[self addEvent:[ZincDownloadBeginEvent downloadBeginEventForURL:request.URL]];

self.httpRequestOperation = requestOp;
self.URLSessionTask = requestTask;

[self queueChildOperation:requestOp];
}

- (void)addProgressTrackingIfNeeded
{
if ([self isFinished]) return;

@synchronized(self) {
if (self.trackingProgress) return;
self.trackingProgress = YES;
}

static const NSTimeInterval minTimeOffsetBetweenEventSends = 0.25f;
__block NSTimeInterval lastTimeEventSentDate = 0;
__weak typeof(self) weakself = self;

[self.httpRequestOperation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {

__weak typeof(weakself) strongself = weakself;

NSTimeInterval currentDate = [[NSDate date] timeIntervalSince1970];
NSTimeInterval timeSinceLastEventSent = currentDate - lastTimeEventSentDate;

BOOL enoughTimePassedSinceLastNotification = timeSinceLastEventSent >= minTimeOffsetBetweenEventSends;
BOOL downloadCompleted = totalBytesRead == totalBytesExpectedToRead;
if (enoughTimePassedSinceLastNotification || downloadCompleted)
{
lastTimeEventSentDate = currentDate;
[strongself updateCurrentBytes:totalBytesRead totalBytes:totalBytesExpectedToRead];
}
}];
// TODO: is this needed?
// [self queueChildOperation:requestOp];
}

- (long long) currentProgressValue
Expand All @@ -84,27 +49,21 @@ - (long long) currentProgressValue
return [self maxProgressValue];
}

[self addProgressTrackingIfNeeded];
return self.bytesRead;
return [self.URLSessionTask countOfBytesReceived];
}

- (long long) maxProgressValue
{
if (self.httpRequestOperation.response != nil) {
return [self.httpRequestOperation.response expectedContentLength];
if (self.URLSessionTask.response != nil) {
return [self.URLSessionTask countOfBytesExpectedToReceive];
}
return [self isFinished] ? 0 : ZincProgressNotYetDetermined;
}

- (void) updateCurrentBytes:(long long)currentBytes totalBytes:(long long)totalBytes
- (long long)bytesRead
{
self.bytesRead = currentBytes;
self.totalBytesToRead = totalBytes; // TODO: totalBytesToRead not used
return [self currentProgressValue];
}

- (void)dealloc
{
[self.httpRequestOperation waitUntilFinished];
}

@end
2 changes: 2 additions & 0 deletions Zinc/Private/ZincEventHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@

+ (NSDictionary *)attributesForRequestOperation:(id<ZincHTTPRequestOperation>)op;

+ (NSDictionary *)attributesForRequest:(NSURLRequest *)request andResponse:(NSURLResponse *)response;

@end
17 changes: 11 additions & 6 deletions Zinc/Private/ZincEventHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,31 @@

@implementation ZincEventHelpers

+ (NSDictionary *)attributesForRequestOperation:(id<ZincHTTPRequestOperation>)op
+ (NSDictionary *)attributesForRequest:(NSURLRequest *)request andResponse:(NSURLResponse *)response
{
NSMutableDictionary* info = [NSMutableDictionary dictionaryWithCapacity:2];

if (op.request != nil) {
if (request != nil) {
NSMutableDictionary* requestInfo = [NSMutableDictionary dictionary];
info[@"URLRequest"] = requestInfo;
requestInfo[@"URL"] = op.request.URL;
requestInfo[@"URL"] = request.URL;
}

if (op.response != nil ) {
if (response != nil ) {
NSMutableDictionary* responseInfo = [NSMutableDictionary dictionary];
info[@"URLResponse"] = responseInfo;
if ([op.response respondsToSelector:@selector(allHeaderFields)]) {
responseInfo[@"Headers"] = [op.response performSelector:@selector(allHeaderFields)];
if ([response respondsToSelector:@selector(allHeaderFields)]) {
responseInfo[@"Headers"] = [response performSelector:@selector(allHeaderFields)];
}
}

return info;

}

+ (NSDictionary *)attributesForRequestOperation:(id<ZincHTTPRequestOperation>)op
{
return [self attributesForRequest:op.request andResponse:op.response];
}

@end
14 changes: 14 additions & 0 deletions Zinc/Private/ZincHTTPURLConnectionOperation+ZincURLSessionTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ZincHTTPURLConnectionOperation+ZincURLSessionTask.h
// Zinc-ObjC
//
// Created by Andy Mroczkowski on 12/12/13.
// Copyright (c) 2013 MindSnacks. All rights reserved.
//

#import "ZincHTTPURLConnectionOperation.h"
#import "ZincURLSession.h"

@interface ZincHTTPURLConnectionOperation (ZincURLSessionTask) <ZincURLSessionTask>

@end
33 changes: 33 additions & 0 deletions Zinc/Private/ZincHTTPURLConnectionOperation+ZincURLSessionTask.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ZincHTTPURLConnectionOperation+ZincURLSessionTask.m
// Zinc-ObjC
//
// Created by Andy Mroczkowski on 12/12/13.
// Copyright (c) 2013 MindSnacks. All rights reserved.
//

#import "ZincHTTPURLConnectionOperation+ZincURLSessionTask.h"

@implementation ZincHTTPURLConnectionOperation (ZincURLSessionTask)

- (NSURLRequest *)originalRequest
{
return self.request;
}

- (NSURLRequest *)currentRequest
{
return self.request;
}

- (int64_t)countOfBytesReceived
{
return self.totalBytesRead;
}

- (int64_t)countOfBytesExpectedToReceive
{
return self.response.expectedContentLength;
}

@end
Loading

0 comments on commit 8436676

Please sign in to comment.