Minor code formatting for initial data capacity from expectedContentLength
This commit is contained in:
parent
d62af91ac9
commit
6572cde680
1 changed files with 4 additions and 6 deletions
|
|
@ -23,7 +23,8 @@
|
||||||
#import "AFHTTPRequestOperation.h"
|
#import "AFHTTPRequestOperation.h"
|
||||||
#import "AFNetworkActivityIndicatorManager.h"
|
#import "AFNetworkActivityIndicatorManager.h"
|
||||||
|
|
||||||
#define AFHTTPMinContentLength 1024 * 1024 * 8
|
static NSUInteger const kAFHTTPMinimumInitialDataCapacity = 1024;
|
||||||
|
static NSUInteger const kAFHTTPMaximumInitialDataCapacity = 1024 * 1024 * 8;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
AFHTTPOperationReadyState = 1,
|
AFHTTPOperationReadyState = 1,
|
||||||
|
|
@ -303,11 +304,8 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
if (self.outputStream) {
|
if (self.outputStream) {
|
||||||
[self.outputStream open];
|
[self.outputStream open];
|
||||||
} else {
|
} else {
|
||||||
NSUInteger contentLength = MAX(abs(response.expectedContentLength), 1024);
|
NSUInteger capacity = MIN(MAX(abs(response.expectedContentLength), kAFHTTPMinimumInitialDataCapacity), kAFHTTPMaximumInitialDataCapacity);
|
||||||
if (contentLength < AFHTTPMinContentLength) {
|
self.dataAccumulator = [NSMutableData dataWithCapacity:capacity];
|
||||||
contentLength = AFHTTPMinContentLength;
|
|
||||||
}
|
|
||||||
self.dataAccumulator = [NSMutableData dataWithCapacity:contentLength];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue