Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix selector warnings, fix warning "ignore declaration shadows a loca…

…l variable" with using MIN inside of MAX
  • Loading branch information...
commit 2fbc30d137e89addf606c303a2ec6551b533e33a 1 parent 908d77a
@steipete steipete authored
Showing with 24 additions and 19 deletions.
  1. +24 −19 AFNetworking/AFHTTPRequestOperation.m
View
43 AFNetworking/AFHTTPRequestOperation.m
@@ -23,6 +23,8 @@
#import "AFHTTPRequestOperation.h"
#import "AFNetworkActivityIndicatorManager.h"
+#define AFHTTPMinContentLength 1024 * 1024 * 8
+
typedef enum {
AFHTTPOperationReadyState = 1,
AFHTTPOperationExecutingState = 2,
@@ -107,6 +109,14 @@ @implementation AFHTTPRequestOperation
static NSThread *_networkRequestThread = nil;
++ (void)networkRequestThreadEntryPoint:(id)object {
+ do {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [[NSRunLoop currentRunLoop] run];
+ [pool drain];
+ } while (YES);
+}
+
+ (NSThread *)networkRequestThread {
static dispatch_once_t oncePredicate;
@@ -118,14 +128,6 @@ + (NSThread *)networkRequestThread {
return _networkRequestThread;
}
-+ (void)networkRequestThreadEntryPoint:(id)object {
- do {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [[NSRunLoop currentRunLoop] run];
- [pool drain];
- } while (YES);
-}
-
+ (id)operationWithRequest:(NSURLRequest *)urlRequest
completion:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error))completion
{
@@ -246,16 +248,6 @@ - (BOOL)isConcurrent {
return YES;
}
-- (void)start {
- if (self.isFinished) {
- return;
- }
-
- self.state = AFHTTPOperationExecutingState;
-
- [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:YES modes:[self.runLoopModes allObjects]];
-}
-
- (void)operationDidStart {
self.connection = [[[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO] autorelease];
@@ -269,6 +261,16 @@ - (void)operationDidStart {
}
+- (void)start {
+ if (self.isFinished) {
+ return;
+ }
+
+ self.state = AFHTTPOperationExecutingState;
+
+ [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:YES modes:[self.runLoopModes allObjects]];
+}
+
- (void)cancel {
self.isCancelled = YES;
@@ -297,7 +299,10 @@ - (void)connection:(NSURLConnection *)connection
if (self.outputStream) {
[self.outputStream open];
} else {
- NSUInteger contentLength = MIN(MAX(abs(response.expectedContentLength), 1024), 1024 * 1024 * 8);
+ NSUInteger contentLength = MAX(abs(response.expectedContentLength), 1024);
+ if (contentLength < AFHTTPMinContentLength) {
+ contentLength = AFHTTPMinContentLength;
+ }
self.dataAccumulator = [NSMutableData dataWithCapacity:contentLength];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.