Adding bytesRead/bytesWritten argument to progress blocks
Changing progress block parameters to use NSInteger instead of NSUInteger
This commit is contained in:
parent
5ec70e7693
commit
1722e0b70d
2 changed files with 12 additions and 12 deletions
|
|
@ -80,7 +80,7 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
|
||||||
NSError *_error;
|
NSError *_error;
|
||||||
|
|
||||||
NSData *_responseBody;
|
NSData *_responseBody;
|
||||||
NSUInteger _totalBytesRead;
|
NSInteger _totalBytesRead;
|
||||||
NSMutableData *_dataAccumulator;
|
NSMutableData *_dataAccumulator;
|
||||||
NSOutputStream *_outputStream;
|
NSOutputStream *_outputStream;
|
||||||
}
|
}
|
||||||
|
|
@ -133,19 +133,19 @@ extern NSString * const AFHTTPOperationDidFinishNotification;
|
||||||
/**
|
/**
|
||||||
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.
|
||||||
|
|
||||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes two arguments: the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times.
|
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times.
|
||||||
|
|
||||||
@see setDownloadProgressBlock
|
@see setDownloadProgressBlock
|
||||||
*/
|
*/
|
||||||
- (void)setUploadProgressBlock:(void (^)(NSUInteger totalBytesWritten, NSUInteger totalBytesExpectedToWrite))block;
|
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets a callback to be called when an undetermined number of bytes have been uploaded to the server.
|
Sets a callback to be called when an undetermined number of bytes have been uploaded to the server.
|
||||||
|
|
||||||
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes two arguments: the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times.
|
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes read since the last time the upload progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times.
|
||||||
|
|
||||||
@see setUploadProgressBlock
|
@see setUploadProgressBlock
|
||||||
*/
|
*/
|
||||||
- (void)setDownloadProgressBlock:(void (^)(NSUInteger totalBytesRead, NSUInteger totalBytesExpectedToRead))block;
|
- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead))block;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ NSString * const AFNetworkingErrorDomain = @"com.alamofire.networking.error";
|
||||||
NSString * const AFHTTPOperationDidStartNotification = @"com.alamofire.networking.http-operation.start";
|
NSString * const AFHTTPOperationDidStartNotification = @"com.alamofire.networking.http-operation.start";
|
||||||
NSString * const AFHTTPOperationDidFinishNotification = @"com.alamofire.networking.http-operation.finish";
|
NSString * const AFHTTPOperationDidFinishNotification = @"com.alamofire.networking.http-operation.finish";
|
||||||
|
|
||||||
typedef void (^AFHTTPRequestOperationProgressBlock)(NSUInteger totalBytes, NSUInteger totalBytesExpected);
|
typedef void (^AFHTTPRequestOperationProgressBlock)(NSInteger bytes, NSInteger totalBytes, NSInteger totalBytesExpected);
|
||||||
typedef void (^AFHTTPRequestOperationCompletionBlock)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error);
|
typedef void (^AFHTTPRequestOperationCompletionBlock)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error);
|
||||||
|
|
||||||
static inline NSString * AFKeyPathFromOperationState(AFHTTPOperationState state) {
|
static inline NSString * AFKeyPathFromOperationState(AFHTTPOperationState state) {
|
||||||
|
|
@ -84,7 +84,7 @@ static inline BOOL AFHTTPOperationStateTransitionIsValid(AFHTTPOperationState fr
|
||||||
@property (readwrite, nonatomic, retain) NSHTTPURLResponse *response;
|
@property (readwrite, nonatomic, retain) NSHTTPURLResponse *response;
|
||||||
@property (readwrite, nonatomic, retain) NSError *error;
|
@property (readwrite, nonatomic, retain) NSError *error;
|
||||||
@property (readwrite, nonatomic, retain) NSData *responseBody;
|
@property (readwrite, nonatomic, retain) NSData *responseBody;
|
||||||
@property (readwrite, nonatomic, assign) NSUInteger totalBytesRead;
|
@property (readwrite, nonatomic, assign) NSInteger totalBytesRead;
|
||||||
@property (readwrite, nonatomic, retain) NSMutableData *dataAccumulator;
|
@property (readwrite, nonatomic, retain) NSMutableData *dataAccumulator;
|
||||||
@property (readwrite, nonatomic, retain) NSOutputStream *outputStream;
|
@property (readwrite, nonatomic, retain) NSOutputStream *outputStream;
|
||||||
@property (readwrite, nonatomic, copy) AFHTTPRequestOperationProgressBlock uploadProgress;
|
@property (readwrite, nonatomic, copy) AFHTTPRequestOperationProgressBlock uploadProgress;
|
||||||
|
|
@ -196,11 +196,11 @@ static NSThread *_networkRequestThread = nil;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setUploadProgressBlock:(void (^)(NSUInteger totalBytesWritten, NSUInteger totalBytesExpectedToWrite))block {
|
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))block {
|
||||||
self.uploadProgress = block;
|
self.uploadProgress = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDownloadProgressBlock:(void (^)(NSUInteger totalBytesRead, NSUInteger totalBytesExpectedToRead))block {
|
- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead))block {
|
||||||
self.downloadProgress = block;
|
self.downloadProgress = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -350,7 +350,7 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.downloadProgress) {
|
if (self.downloadProgress) {
|
||||||
self.downloadProgress(self.totalBytesRead, (NSUInteger)self.response.expectedContentLength);
|
self.downloadProgress([data length], self.totalBytesRead, (NSInteger)self.response.expectedContentLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -380,12 +380,12 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)__unused connection
|
- (void)connection:(NSURLConnection *)__unused connection
|
||||||
didSendBodyData:(NSInteger)__unused bytesWritten
|
didSendBodyData:(NSInteger)bytesWritten
|
||||||
totalBytesWritten:(NSInteger)totalBytesWritten
|
totalBytesWritten:(NSInteger)totalBytesWritten
|
||||||
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
|
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
|
||||||
{
|
{
|
||||||
if (self.uploadProgress) {
|
if (self.uploadProgress) {
|
||||||
self.uploadProgress(totalBytesWritten, totalBytesExpectedToWrite);
|
self.uploadProgress(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue