fixes an integer overflow for files > 2GB

This commit is contained in:
Peter Steinberger 2012-03-25 01:50:02 -07:00
parent 49186d9a30
commit 2b2558a90e
2 changed files with 8 additions and 8 deletions

View file

@ -89,7 +89,7 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
NSError *_error; NSError *_error;
NSData *_responseData; NSData *_responseData;
NSInteger _totalBytesRead; long long _totalBytesRead;
NSMutableData *_dataAccumulator; NSMutableData *_dataAccumulator;
NSOutputStream *_outputStream; NSOutputStream *_outputStream;
} }
@ -180,7 +180,7 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
@see setDownloadProgressBlock @see setDownloadProgressBlock
*/ */
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))block; - (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;
/** /**
Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
@ -189,7 +189,7 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
@see setUploadProgressBlock @see setUploadProgressBlock
*/ */
- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead))block; - (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block;
///------------------------------------------------- ///-------------------------------------------------
/// @name Setting NSURLConnection Delegate Callbacks /// @name Setting NSURLConnection Delegate Callbacks

View file

@ -40,7 +40,7 @@ NSString * const AFNetworkingErrorDomain = @"com.alamofire.networking.error";
NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start";
NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish";
typedef void (^AFURLConnectionOperationProgressBlock)(NSInteger bytes, NSInteger totalBytes, NSInteger totalBytesExpected); typedef void (^AFURLConnectionOperationProgressBlock)(NSInteger bytes, long long totalBytes, long long totalBytesExpected);
typedef BOOL (^AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace); typedef BOOL (^AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace);
typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge);
typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse);
@ -92,7 +92,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
@property (readwrite, nonatomic, retain) NSError *error; @property (readwrite, nonatomic, retain) NSError *error;
@property (readwrite, nonatomic, retain) NSData *responseData; @property (readwrite, nonatomic, retain) NSData *responseData;
@property (readwrite, nonatomic, copy) NSString *responseString; @property (readwrite, nonatomic, copy) NSString *responseString;
@property (readwrite, nonatomic, assign) NSInteger totalBytesRead; @property (readwrite, nonatomic, assign) long long totalBytesRead;
@property (readwrite, nonatomic, retain) NSMutableData *dataAccumulator; @property (readwrite, nonatomic, retain) NSMutableData *dataAccumulator;
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; @property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress;
@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress; @property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress;
@ -229,11 +229,11 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
self.request = mutableRequest; self.request = mutableRequest;
} }
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))block { - (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
self.uploadProgress = block; self.uploadProgress = block;
} }
- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead))block { - (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block {
self.downloadProgress = block; self.downloadProgress = block;
} }
@ -468,7 +468,7 @@ didReceiveResponse:(NSURLResponse *)response
} }
if (self.downloadProgress) { if (self.downloadProgress) {
self.downloadProgress([data length], self.totalBytesRead, (NSInteger)self.response.expectedContentLength); self.downloadProgress((long long)[data length], self.totalBytesRead, self.response.expectedContentLength);
} }
} }