Changing AFHTTPRequestOperation internal designated initializer from -initWithURLRequest: to -init
This commit is contained in:
parent
1ec555dde5
commit
665bbc541a
1 changed files with 9 additions and 9 deletions
|
|
@ -91,7 +91,6 @@ static inline BOOL AFHTTPOperationStateTransitionIsValid(AFHTTPOperationState fr
|
||||||
@property (readwrite, nonatomic, copy) AFHTTPRequestOperationProgressBlock downloadProgress;
|
@property (readwrite, nonatomic, copy) AFHTTPRequestOperationProgressBlock downloadProgress;
|
||||||
@property (readwrite, nonatomic, copy) AFHTTPRequestOperationCompletionBlock completion;
|
@property (readwrite, nonatomic, copy) AFHTTPRequestOperationCompletionBlock completion;
|
||||||
|
|
||||||
- (id)initWithRequest:(NSURLRequest *)urlRequest;
|
|
||||||
- (void)operationDidStart;
|
- (void)operationDidStart;
|
||||||
- (void)finish;
|
- (void)finish;
|
||||||
@end
|
@end
|
||||||
|
|
@ -136,7 +135,8 @@ static NSThread *_networkRequestThread = nil;
|
||||||
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
+ (AFHTTPRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||||
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
|
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
|
||||||
{
|
{
|
||||||
AFHTTPRequestOperation *operation = [[[self alloc] initWithRequest:urlRequest] autorelease];
|
AFHTTPRequestOperation *operation = [[[self alloc] init] autorelease];
|
||||||
|
operation.request = urlRequest;
|
||||||
operation.completion = completion;
|
operation.completion = completion;
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
|
|
@ -166,14 +166,12 @@ static NSThread *_networkRequestThread = nil;
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithRequest:(NSURLRequest *)urlRequest {
|
- (id)init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.request = urlRequest;
|
|
||||||
|
|
||||||
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
|
self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
|
||||||
|
|
||||||
self.state = AFHTTPOperationReadyState;
|
self.state = AFHTTPOperationReadyState;
|
||||||
|
|
@ -330,7 +328,9 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
if (self.outputStream) {
|
if (self.outputStream) {
|
||||||
[self.outputStream open];
|
[self.outputStream open];
|
||||||
} else {
|
} else {
|
||||||
NSUInteger capacity = MIN(MAX(abs(response.expectedContentLength), kAFHTTPMinimumInitialDataCapacity), kAFHTTPMaximumInitialDataCapacity);
|
|
||||||
|
NSUInteger maxCapacity = MAX((NSUInteger)llabs(response.expectedContentLength), kAFHTTPMinimumInitialDataCapacity);
|
||||||
|
NSUInteger capacity = MIN(maxCapacity, kAFHTTPMaximumInitialDataCapacity);
|
||||||
self.dataAccumulator = [NSMutableData dataWithCapacity:capacity];
|
self.dataAccumulator = [NSMutableData dataWithCapacity:capacity];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -350,7 +350,7 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.downloadProgress) {
|
if (self.downloadProgress) {
|
||||||
self.downloadProgress(self.totalBytesRead, self.response.expectedContentLength);
|
self.downloadProgress(self.totalBytesRead, (NSUInteger)self.response.expectedContentLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue