diff --git a/ASIHTTPRequest.podspec b/ASIHTTPRequest.podspec new file mode 100644 index 00000000..4a2128e9 --- /dev/null +++ b/ASIHTTPRequest.podspec @@ -0,0 +1,61 @@ +Pod::Spec.new do |s| + s.name = 'ASIHTTPRequest' + s.version = '1.8.2' + s.summary = 'Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone.' + s.homepage = 'http://allseeing-i.com/ASIHTTPRequest' + s.author = { 'Ben Copsey' => 'ben@allseeing-i.com' } + s.license = 'New BSD License' + s.source = { :git => 'https://github.com/pokeb/asi-http-request.git', :tag => 'v1.8.2' } + + s.description = %{ + ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that + makes some of the more tedious aspects of communicating with web servers + easier. It is written in Objective-C and works in both Mac OS X and iPhone + applications. + + It is suitable performing basic HTTP requests and interacting with + REST-based services (GET / POST / PUT / DELETE). The included + ASIFormDataRequest subclass makes it easy to submit POST data and files + using multipart/form-data. + + Please note that ASIHTTPRequest is not recommended for newer projects + since it's not actively maintained anymore. + + For more info visit: http://allseeing-i.com/%5Brequest_release%5D + } + + s.requires_arc = true + s.ios.deployment_target = '8.0' + # s.osx.deployment_target = '10.6' + + s.subspec 'Core' do |core| + core.source_files = 'Classes/*.{h,m}' + core.ios.dependency 'Reachability' #, '~> 2.0', '>= 2.0.4' + core.ios.frameworks = 'MobileCoreServices', 'CFNetwork', 'CoreGraphics' + + core.osx.exclude_files = '**/*ASIAuthenticationDialog*' + core.osx.frameworks = 'SystemConfiguration', 'CoreServices' + + core.libraries = 'z.1' + end + + s.subspec 'ASIWebPageRequest' do |ws| + ws.requires_arc = false + ws.source_files = 'Classes/ASIWebPageRequest/*.{h,m}' + ws.libraries = 'xml2.2' + ws.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(SDKROOT)/usr/include/libxml2"' } + ws.dependency 'ASIHTTPRequest/Core' + end + + s.subspec 'CloudFiles' do |cfs| + cfs.requires_arc = false + cfs.source_files = 'Classes/CloudFiles/*.{h,m}','Classes/S3/ASINSXMLParserCompat.h' + cfs.dependency 'ASIHTTPRequest/Core' + end + + s.subspec 'S3' do |s3s| + s3s.requires_arc = false + s3s.source_files = 'Classes/S3/*.{h,m}' + s3s.dependency 'ASIHTTPRequest/Core' + end +end diff --git a/Classes/ASIAuthenticationDialog.m b/Classes/ASIAuthenticationDialog.m index 64c220e9..a393e874 100644 --- a/Classes/ASIAuthenticationDialog.m +++ b/Classes/ASIAuthenticationDialog.m @@ -51,7 +51,7 @@ @implementation ASIAuthenticationDialog + (void)initialize { if (self == [ASIAuthenticationDialog class]) { - requestsNeedingAuthentication = [[NSMutableArray array] retain]; + requestsNeedingAuthentication = [NSMutableArray array]; } } @@ -98,12 +98,7 @@ - (void)dealloc [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; } [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; - - [request release]; - [tableView release]; [presentingController.view removeFromSuperview]; - [presentingController release]; - [super dealloc]; } #pragma mark keyboard notifications @@ -132,8 +127,8 @@ - (void)keyboardWillShow:(NSNotification *)notification - (void)orientationChanged:(NSNotification *)notification { [self showTitle]; - - UIInterfaceOrientation o = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation]; +#ifndef TARGET_IS_EXTENSION + UIDeviceOrientation o = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation]; CGFloat angle = 0; switch (o) { case UIDeviceOrientationLandscapeLeft: angle = 90; break; @@ -171,6 +166,7 @@ - (void)orientationChanged:(NSNotification *)notification // Fix the view origin self.view.frame = (CGRect){ { f.origin.x, f.origin.y },self.view.frame.size}; [UIView commitAnimations]; +#endif } #pragma mark utilities @@ -181,10 +177,12 @@ - (UIViewController *)presentingController presentingController = [[ASIAutorotatingViewController alloc] initWithNibName:nil bundle:nil]; // Attach to the window, but don't interfere. +#ifndef TARGET_IS_EXTENSION UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; [window addSubview:[presentingController view]]; [[presentingController view] setFrame:CGRectZero]; [[presentingController view] setUserInteractionEnabled:NO]; +#endif } return presentingController; @@ -234,11 +232,10 @@ + (void)dismiss - (void)viewDidDisappear:(BOOL)animated { - [self retain]; - [sharedDialog release]; - sharedDialog = nil; [self performSelector:@selector(presentNextDialog) withObject:nil afterDelay:0]; - [self release]; + sharedDialog = nil; + + [super viewDidDisappear:animated]; } - (void)dismiss @@ -267,12 +264,12 @@ - (void)showTitle { UINavigationBar *navigationBar = [[[self view] subviews] objectAtIndex:0]; UINavigationItem *navItem = [[navigationBar items] objectAtIndex:0]; - if (UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation])) { + if (UIInterfaceOrientationIsPortrait((UIInterfaceOrientation)[[UIDevice currentDevice] orientation])) { // Setup the title if ([self type] == ASIProxyAuthenticationType) { - [navItem setPrompt:@"Login to this secure proxy server."]; + [navItem setPrompt:NSLocalizedString(@"Login to this secure proxy server.", nil)]; } else { - [navItem setPrompt:@"Login to this secure server."]; + [navItem setPrompt:NSLocalizedString(@"Login to this secure server.", nil)]; } } else { [navItem setPrompt:nil]; @@ -293,10 +290,10 @@ - (void)show } // Setup toolbar - UINavigationBar *bar = [[[UINavigationBar alloc] init] autorelease]; + UINavigationBar *bar = [[UINavigationBar alloc] init]; [bar setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; - UINavigationItem *navItem = [[[UINavigationItem alloc] init] autorelease]; + UINavigationItem *navItem = [[UINavigationItem alloc] init]; bar.items = [NSArray arrayWithObject:navItem]; [[self view] addSubview:bar]; @@ -310,8 +307,8 @@ - (void)show [navItem setTitle:[[[self request] url] host]]; } - [navItem setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelAuthenticationFromDialog:)] autorelease]]; - [navItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithTitle:@"Login" style:UIBarButtonItemStyleDone target:self action:@selector(loginWithCredentialsFromDialog:)] autorelease]]; + [navItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelAuthenticationFromDialog:)]]; + [navItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Login", nil) style:UIBarButtonItemStyleDone target:self action:@selector(loginWithCredentialsFromDialog:)]]; // We show the login form in a table view, similar to Safari's authentication dialog [bar sizeToFit]; @@ -319,7 +316,7 @@ - (void)show f.origin.y = [bar frame].size.height; f.size.height -= f.origin.y; - [self setTableView:[[[UITableView alloc] initWithFrame:f style:UITableViewStyleGrouped] autorelease]]; + [self setTableView:[[UITableView alloc] initWithFrame:f style:UITableViewStyleGrouped]]; [[self tableView] setDelegate:self]; [[self tableView] setDataSource:self]; [[self tableView] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; @@ -458,7 +455,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0 - UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease]; + UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; #else UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,0,0) reuseIdentifier:nil] autorelease]; #endif @@ -466,7 +463,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; CGRect f = CGRectInset([cell bounds], 10, 10); - UITextField *textField = [[[UITextField alloc] initWithFrame:f] autorelease]; + UITextField *textField = [[UITextField alloc] initWithFrame:f]; [textField setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; [textField setAutocapitalizationType:UITextAutocapitalizationTypeNone]; [textField setAutocorrectionType:UITextAutocorrectionTypeNo]; @@ -475,12 +472,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N NSInteger r = [indexPath row]; if (s == kUsernameSection && r == kUsernameRow) { - [textField setPlaceholder:@"User"]; + [textField setPlaceholder:NSLocalizedString(@"User", nil)]; } else if (s == kPasswordSection && r == kPasswordRow) { - [textField setPlaceholder:@"Password"]; + [textField setPlaceholder:NSLocalizedString(@"Password", nil)]; [textField setSecureTextEntry:YES]; } else if (s == kDomainSection && r == kDomainRow) { - [textField setPlaceholder:@"Domain"]; + [textField setPlaceholder:NSLocalizedString(@"Domain", nil)]; } [cell.contentView addSubview:textField]; diff --git a/Classes/ASICacheDelegate.h b/Classes/ASICacheDelegate.h index 060cda59..9de64a84 100644 --- a/Classes/ASICacheDelegate.h +++ b/Classes/ASICacheDelegate.h @@ -15,37 +15,37 @@ // Note that some of the behaviours below are mutally exclusive - you cannot combine ASIAskServerIfModifiedWhenStaleCachePolicy and ASIAskServerIfModifiedCachePolicy, for example. typedef enum _ASICachePolicy { - // The default cache policy. When you set a request to use this, it will use the cache's defaultCachePolicy - // ASIDownloadCache's default cache policy is 'ASIAskServerIfModifiedWhenStaleCachePolicy' - ASIUseDefaultCachePolicy = 0, + // The default cache policy. When you set a request to use this, it will use the cache's defaultCachePolicy + // ASIDownloadCache's default cache policy is 'ASIAskServerIfModifiedWhenStaleCachePolicy' + ASIUseDefaultCachePolicy = 0, - // Tell the request not to read from the cache - ASIDoNotReadFromCacheCachePolicy = 1, + // Tell the request not to read from the cache + ASIDoNotReadFromCacheCachePolicy = 1, - // The the request not to write to the cache - ASIDoNotWriteToCacheCachePolicy = 2, + // The the request not to write to the cache + ASIDoNotWriteToCacheCachePolicy = 2, - // Ask the server if there is an updated version of this resource (using a conditional GET) ONLY when the cached data is stale - ASIAskServerIfModifiedWhenStaleCachePolicy = 4, + // Ask the server if there is an updated version of this resource (using a conditional GET) ONLY when the cached data is stale + ASIAskServerIfModifiedWhenStaleCachePolicy = 4, - // Always ask the server if there is an updated version of this resource (using a conditional GET) - ASIAskServerIfModifiedCachePolicy = 8, + // Always ask the server if there is an updated version of this resource (using a conditional GET) + ASIAskServerIfModifiedCachePolicy = 8, - // If cached data exists, use it even if it is stale. This means requests will not talk to the server unless the resource they are requesting is not in the cache - ASIOnlyLoadIfNotCachedCachePolicy = 16, + // If cached data exists, use it even if it is stale. This means requests will not talk to the server unless the resource they are requesting is not in the cache + ASIOnlyLoadIfNotCachedCachePolicy = 16, - // If cached data exists, use it even if it is stale. If cached data does not exist, stop (will not set an error on the request) - ASIDontLoadCachePolicy = 32, + // If cached data exists, use it even if it is stale. If cached data does not exist, stop (will not set an error on the request) + ASIDontLoadCachePolicy = 32, - // Specifies that cached data may be used if the request fails. If cached data is used, the request will succeed without error. Usually used in combination with other options above. - ASIFallbackToCacheIfLoadFailsCachePolicy = 64 + // Specifies that cached data may be used if the request fails. If cached data is used, the request will succeed without error. Usually used in combination with other options above. + ASIFallbackToCacheIfLoadFailsCachePolicy = 64 } ASICachePolicy; // Cache storage policies control whether cached data persists between application launches (ASICachePermanentlyCacheStoragePolicy) or not (ASICacheForSessionDurationCacheStoragePolicy) // Calling [ASIHTTPRequest clearSession] will remove any data stored using ASICacheForSessionDurationCacheStoragePolicy typedef enum _ASICacheStoragePolicy { - ASICacheForSessionDurationCacheStoragePolicy = 0, - ASICachePermanentlyCacheStoragePolicy = 1 + ASICacheForSessionDurationCacheStoragePolicy = 0, + ASICachePermanentlyCacheStoragePolicy = 1 } ASICacheStoragePolicy; diff --git a/Classes/ASIDataCompressor.h b/Classes/ASIDataCompressor.h index fb57a1a9..72bd1a75 100644 --- a/Classes/ASIDataCompressor.h +++ b/Classes/ASIDataCompressor.h @@ -14,12 +14,11 @@ #import @interface ASIDataCompressor : NSObject { - BOOL streamReady; - z_stream zStream; + z_stream zStream; } // Convenience constructor will call setupStream for you -+ (id)compressor; ++ (instancetype)compressor; // Compress the passed chunk of data // Passing YES for shouldFinish will finalize the deflated data - you must pass YES when you are on the last chunk of data diff --git a/Classes/ASIDataCompressor.m b/Classes/ASIDataCompressor.m index 41dce4e5..e9fb8b71 100644 --- a/Classes/ASIDataCompressor.m +++ b/Classes/ASIDataCompressor.m @@ -18,24 +18,23 @@ + (NSError *)deflateErrorWithCode:(int)code; @implementation ASIDataCompressor -+ (id)compressor ++ (instancetype)compressor { - ASIDataCompressor *compressor = [[[self alloc] init] autorelease]; + ASIDataCompressor *compressor = [[self alloc] init]; [compressor setupStream]; return compressor; } - (void)dealloc { - if (streamReady) { + if (_streamReady) { [self closeStream]; } - [super dealloc]; } - (NSError *)setupStream { - if (streamReady) { + if (_streamReady) { return nil; } // Setup the inflate stream @@ -48,17 +47,17 @@ - (NSError *)setupStream if (status != Z_OK) { return [[self class] deflateErrorWithCode:status]; } - streamReady = YES; + _streamReady = YES; return nil; } - (NSError *)closeStream { - if (!streamReady) { + if (!_streamReady) { return nil; } // Close the deflate stream - streamReady = NO; + _streamReady = NO; int status = deflateEnd(&zStream); if (status != Z_OK) { return [[self class] deflateErrorWithCode:status]; @@ -98,7 +97,7 @@ - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSErro if (err) { *err = [[self class] deflateErrorWithCode:status]; } - return NO; + return nil; } } @@ -125,7 +124,7 @@ + (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err + (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; // Create an empty file at the destination path if (![fileManager createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) { @@ -215,5 +214,4 @@ + (NSError *)deflateErrorWithCode:(int)code return [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of data failed with code %d",code],NSLocalizedDescriptionKey,nil]]; } -@synthesize streamReady; @end diff --git a/Classes/ASIDataDecompressor.h b/Classes/ASIDataDecompressor.h index 32a40a94..95160945 100644 --- a/Classes/ASIDataDecompressor.h +++ b/Classes/ASIDataDecompressor.h @@ -14,12 +14,11 @@ #import @interface ASIDataDecompressor : NSObject { - BOOL streamReady; z_stream zStream; } // Convenience constructor will call setupStream for you -+ (id)decompressor; ++ (instancetype)decompressor; // Uncompress the passed chunk of data - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err; diff --git a/Classes/ASIDataDecompressor.m b/Classes/ASIDataDecompressor.m index fa0ef013..7789e7a5 100644 --- a/Classes/ASIDataDecompressor.m +++ b/Classes/ASIDataDecompressor.m @@ -17,24 +17,23 @@ + (NSError *)inflateErrorWithCode:(int)code; @implementation ASIDataDecompressor -+ (id)decompressor ++ (instancetype)decompressor { - ASIDataDecompressor *decompressor = [[[self alloc] init] autorelease]; + ASIDataDecompressor *decompressor = [[self alloc] init]; [decompressor setupStream]; return decompressor; } - (void)dealloc { - if (streamReady) { + if (_streamReady) { [self closeStream]; } - [super dealloc]; } - (NSError *)setupStream { - if (streamReady) { + if (_streamReady) { return nil; } // Setup the inflate stream @@ -47,17 +46,17 @@ - (NSError *)setupStream if (status != Z_OK) { return [[self class] inflateErrorWithCode:status]; } - streamReady = YES; + _streamReady = YES; return nil; } - (NSError *)closeStream { - if (!streamReady) { + if (!_streamReady) { return nil; } // Close the inflate stream - streamReady = NO; + _streamReady = NO; int status = inflateEnd(&zStream); if (status != Z_OK) { return [[self class] inflateErrorWithCode:status]; @@ -121,7 +120,7 @@ + (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; // Create an empty file at the destination path if (![fileManager createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) { @@ -214,5 +213,4 @@ + (NSError *)inflateErrorWithCode:(int)code return [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of data failed with code %d",code],NSLocalizedDescriptionKey,nil]]; } -@synthesize streamReady; @end diff --git a/Classes/ASIDownloadCache.h b/Classes/ASIDownloadCache.h index 967ddbe8..8b7dd146 100644 --- a/Classes/ASIDownloadCache.h +++ b/Classes/ASIDownloadCache.h @@ -16,10 +16,6 @@ // Defaults to ASIAskServerIfModifiedWhenStaleCachePolicy ASICachePolicy defaultCachePolicy; - // The directory in which cached data will be stored - // Defaults to a directory called 'ASIHTTPRequestCache' in the temporary directory - NSString *storagePath; - // Mediates access to the cache NSRecursiveLock *accessLock; @@ -40,6 +36,9 @@ + (NSArray *)fileExtensionsToHandleAsHTML; @property (assign, nonatomic) ASICachePolicy defaultCachePolicy; + +// The directory in which cached data will be stored +// Defaults to a directory called 'ASIHTTPRequestCache' in the temporary directory @property (retain, nonatomic) NSString *storagePath; @property (atomic, retain) NSRecursiveLock *accessLock; @property (atomic, assign) BOOL shouldRespectCacheControlHeaders; diff --git a/Classes/ASIDownloadCache.m b/Classes/ASIDownloadCache.m index 93da36fb..fd22da3e 100644 --- a/Classes/ASIDownloadCache.m +++ b/Classes/ASIDownloadCache.m @@ -37,7 +37,7 @@ - (id)init self = [super init]; [self setShouldRespectCacheControlHeaders:YES]; [self setDefaultCachePolicy:ASIUseDefaultCachePolicy]; - [self setAccessLock:[[[NSRecursiveLock alloc] init] autorelease]]; + [self setAccessLock:[[NSRecursiveLock alloc] init]]; return self; } @@ -54,30 +54,13 @@ + (id)sharedCache return sharedCache; } -- (void)dealloc -{ - [storagePath release]; - [accessLock release]; - [super dealloc]; -} - -- (NSString *)storagePath -{ - [[self accessLock] lock]; - NSString *p = [[storagePath retain] autorelease]; - [[self accessLock] unlock]; - return p; -} - - - (void)setStoragePath:(NSString *)path { [[self accessLock] lock]; [self clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy]; - [storagePath release]; - storagePath = [path retain]; + _storagePath = path; - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; BOOL isDirectory = NO; NSArray *directories = [NSArray arrayWithObjects:path,[path stringByAppendingPathComponent:sessionCacheFolder],[path stringByAppendingPathComponent:permanentCacheFolder],nil]; @@ -176,7 +159,6 @@ - (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval [manager removeItemAtPath:dataPath error:&error]; } [manager copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error]; - [manager release]; } [[self accessLock] unlock]; } @@ -231,7 +213,7 @@ - (NSString *)pathToFile:(NSString *)file return nil; } - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; // Look in the session store NSString *dataPath = [[[self storagePath] stringByAppendingPathComponent:sessionCacheFolder] stringByAppendingPathComponent:file]; @@ -293,7 +275,7 @@ - (void)removeCachedDataForURL:(NSURL *)url [[self accessLock] unlock]; return; } - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; NSString *path = [self pathToCachedResponseHeadersForURL:url]; if (path) { @@ -354,7 +336,7 @@ - (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request // Look for X-ASIHTTPRequest-Expires header to see if the content is out of date NSNumber *expires = [cachedHeaders objectForKey:@"X-ASIHTTPRequest-Expires"]; - if (expires) { + if (expires != nil) { if ([[NSDate dateWithTimeIntervalSince1970:[expires doubleValue]] timeIntervalSinceNow] >= 0) { [[self accessLock] unlock]; return YES; @@ -400,7 +382,7 @@ - (void)clearCachedResponsesForStoragePolicy:(ASICacheStoragePolicy)storagePolic } NSString *path = [[self storagePath] stringByAppendingPathComponent:(storagePolicy == ASICacheForSessionDurationCacheStoragePolicy ? sessionCacheFolder : permanentCacheFolder)]; - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; BOOL isDirectory = NO; BOOL exists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory]; @@ -507,7 +489,6 @@ - (BOOL)canUseCachedDataForRequest:(ASIHTTPRequest *)request return NO; } -@synthesize storagePath; @synthesize defaultCachePolicy; @synthesize accessLock; @synthesize shouldRespectCacheControlHeaders; diff --git a/Classes/ASIFormDataRequest.h b/Classes/ASIFormDataRequest.h index 15138901..e23071dc 100644 --- a/Classes/ASIFormDataRequest.h +++ b/Classes/ASIFormDataRequest.h @@ -16,24 +16,7 @@ typedef enum _ASIPostFormat { } ASIPostFormat; -@interface ASIFormDataRequest : ASIHTTPRequest { - - // Parameters that will be POSTed to the url - NSMutableArray *postData; - - // Files that will be POSTed to the url - NSMutableArray *fileData; - - ASIPostFormat postFormat; - - NSStringEncoding stringEncoding; - -#if DEBUG_FORM_DATA_REQUEST - // Will store a string version of the request body that will be printed to the console when ASIHTTPREQUEST_DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS - NSString *debugBodyString; -#endif - -} +@interface ASIFormDataRequest : ASIHTTPRequest #pragma mark utilities - (NSString*)encodeURL:(NSString *)string; diff --git a/Classes/ASIFormDataRequest.m b/Classes/ASIFormDataRequest.m index 47f2e294..77e0bd6e 100644 --- a/Classes/ASIFormDataRequest.m +++ b/Classes/ASIFormDataRequest.m @@ -15,11 +15,16 @@ - (void)buildMultipartFormDataPostBody; - (void)buildURLEncodedPostBody; - (void)appendPostString:(NSString *)string; +// Parameters that will be POSTed to the url @property (atomic, retain) NSMutableArray *postData; + +// Files that will be POSTed to the url @property (atomic, retain) NSMutableArray *fileData; #if DEBUG_FORM_DATA_REQUEST - (void)addToDebugBody:(NSString *)string; + +// Will store a string version of the request body that will be printed to the console when ASIHTTPREQUEST_DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS @property (retain, nonatomic) NSString *debugBodyString; #endif @@ -30,7 +35,7 @@ @implementation ASIFormDataRequest #pragma mark utilities - (NSString*)encodeURL:(NSString *)string { - NSString *newString = [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding]))) autorelease]; + NSString *newString = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding]))); if (newString) { return newString; } @@ -41,7 +46,7 @@ - (NSString*)encodeURL:(NSString *)string + (id)requestWithURL:(NSURL *)newURL { - return [[[self alloc] initWithURL:newURL] autorelease]; + return [[self alloc] initWithURL:newURL]; } - (id)initWithURL:(NSURL *)newURL @@ -53,17 +58,6 @@ - (id)initWithURL:(NSURL *)newURL return self; } -- (void)dealloc -{ -#if DEBUG_FORM_DATA_REQUEST - [debugBodyString release]; -#endif - - [postData release]; - [fileData release]; - [super dealloc]; -} - #pragma mark setup request - (void)addPostValue:(id )value forKey:(NSString *)key @@ -103,7 +97,7 @@ - (void)addFile:(NSString *)filePath forKey:(NSString *)key - (void)addFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key { BOOL isDirectory = NO; - BOOL fileExists = [[[[NSFileManager alloc] init] autorelease] fileExistsAtPath:filePath isDirectory:&isDirectory]; + BOOL fileExists = [[[NSFileManager alloc] init] fileExistsAtPath:filePath isDirectory:&isDirectory]; if (!fileExists || isDirectory) { [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIInternalErrorWhileBuildingRequestType userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"No file exists at %@",filePath],NSLocalizedDescriptionKey,nil]]]; } @@ -213,6 +207,19 @@ - (void)buildPostBody #endif } +- (BOOL)isHeaderContainsContentType +{ + BOOL headerContainsContentType = NO; + for (id key in self.requestHeaders.allKeys) + { + if ([key isKindOfClass:[NSString class]] && [key isEqualToString:@"Content-Type"]) + { + headerContainsContentType = YES; + break; + } + } + return headerContainsContentType; +} - (void)buildMultipartFormDataPostBody { @@ -220,16 +227,19 @@ - (void)buildMultipartFormDataPostBody [self addToDebugBody:@"\r\n==== Building a multipart/form-data body ====\r\n"]; #endif - NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding])); + NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding])); // We don't bother to check if post data contains the boundary, since it's pretty unlikely that it does. CFUUIDRef uuid = CFUUIDCreate(nil); - NSString *uuidString = [(NSString*)CFUUIDCreateString(nil, uuid) autorelease]; + NSString *uuidString = (NSString*)CFBridgingRelease(CFUUIDCreateString(nil, uuid)); CFRelease(uuid); NSString *stringBoundary = [NSString stringWithFormat:@"0xKhTmLbOuNdArY-%@",uuidString]; - [self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, stringBoundary]]; - + if (![self isHeaderContainsContentType]) + { + [self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, stringBoundary]]; + } + [self appendPostString:[NSString stringWithFormat:@"--%@\r\n",stringBoundary]]; // Adds post data @@ -288,7 +298,10 @@ - (void)buildURLEncodedPostBody NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding])); - [self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@",charset]]; + if (![self isHeaderContainsContentType]) + { + [self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@",charset]]; + } NSUInteger i=0; @@ -344,19 +357,12 @@ - (void)addToDebugBody:(NSString *)string - (id)copyWithZone:(NSZone *)zone { ASIFormDataRequest *newRequest = [super copyWithZone:zone]; - [newRequest setPostData:[[[self postData] mutableCopyWithZone:zone] autorelease]]; - [newRequest setFileData:[[[self fileData] mutableCopyWithZone:zone] autorelease]]; + [newRequest setPostData:[[self postData] mutableCopyWithZone:zone]]; + [newRequest setFileData:[[self fileData] mutableCopyWithZone:zone]]; [newRequest setPostFormat:[self postFormat]]; [newRequest setStringEncoding:[self stringEncoding]]; [newRequest setRequestMethod:[self requestMethod]]; return newRequest; } -@synthesize postData; -@synthesize fileData; -@synthesize postFormat; -@synthesize stringEncoding; -#if DEBUG_FORM_DATA_REQUEST -@synthesize debugBodyString; -#endif @end diff --git a/Classes/ASIHTTPRequest.h b/Classes/ASIHTTPRequest.h index 31582b23..362fa8f7 100644 --- a/Classes/ASIHTTPRequest.h +++ b/Classes/ASIHTTPRequest.h @@ -82,323 +82,89 @@ typedef void (^ASIDataBlock)(NSData *data); #endif @interface ASIHTTPRequest : NSOperation { - - // The url for this operation, should include GET params in the query string where appropriate - NSURL *url; - - // Will always contain the original url used for making the request (the value of url can change when a request is redirected) - NSURL *originalURL; - - // Temporarily stores the url we are about to redirect to. Will be nil again when we do redirect - NSURL *redirectURL; - - // The delegate - will be notified of various changes in state via the ASIHTTPRequestDelegate protocol - id delegate; - - // Another delegate that is also notified of request status changes and progress updates - // Generally, you won't use this directly, but ASINetworkQueue sets itself as the queue so it can proxy updates to its own delegates - // NOTE: WILL BE RETAINED BY THE REQUEST - id queue; - - // HTTP method to use (eg: GET / POST / PUT / DELETE / HEAD etc). Defaults to GET - NSString *requestMethod; - - // Request body - only used when the whole body is stored in memory (shouldStreamPostDataFromDisk is false) - NSMutableData *postBody; - - // gzipped request body used when shouldCompressRequestBody is YES - NSData *compressedPostBody; - - // When true, post body will be streamed from a file on disk, rather than loaded into memory at once (useful for large uploads) - // Automatically set to true in ASIFormDataRequests when using setFile:forKey: - BOOL shouldStreamPostDataFromDisk; - - // Path to file used to store post body (when shouldStreamPostDataFromDisk is true) - // You can set this yourself - useful if you want to PUT a file from local disk - NSString *postBodyFilePath; - - // Path to a temporary file used to store a deflated post body (when shouldCompressPostBody is YES) - NSString *compressedPostBodyFilePath; - - // Set to true when ASIHTTPRequest automatically created a temporary file containing the request body (when true, the file at postBodyFilePath will be deleted at the end of the request) - BOOL didCreateTemporaryPostDataFile; - - // Used when writing to the post body when shouldStreamPostDataFromDisk is true (via appendPostData: or appendPostDataFromFile:) - NSOutputStream *postBodyWriteStream; - - // Used for reading from the post body when sending the request - NSInputStream *postBodyReadStream; - - // Dictionary for custom HTTP request headers - NSMutableDictionary *requestHeaders; - // Set to YES when the request header dictionary has been populated, used to prevent this happening more than once BOOL haveBuiltRequestHeaders; - // Will be populated with HTTP response headers from the server - NSDictionary *responseHeaders; - - // Can be used to manually insert cookie headers to a request, but it's more likely that sessionCookies will do this for you - NSMutableArray *requestCookies; - - // Will be populated with cookies - NSArray *responseCookies; - - // If use useCookiePersistence is true, network requests will present valid cookies from previous requests - BOOL useCookiePersistence; - // If useKeychainPersistence is true, network requests will attempt to read credentials from the keychain, and will save them in the keychain when they are successfully presented BOOL useKeychainPersistence; - // If useSessionPersistence is true, network requests will save credentials and reuse for the duration of the session (until clearSession is called) - BOOL useSessionPersistence; - - // If allowCompressedResponse is true, requests will inform the server they can accept compressed data, and will automatically decompress gzipped responses. Default is true. - BOOL allowCompressedResponse; - - // If shouldCompressRequestBody is true, the request body will be gzipped. Default is false. - // You will probably need to enable this feature on your webserver to make this work. Tested with apache only. - BOOL shouldCompressRequestBody; - - // When downloadDestinationPath is set, the result of this request will be downloaded to the file at this location - // If downloadDestinationPath is not set, download data will be stored in memory - NSString *downloadDestinationPath; - - // The location that files will be downloaded to. Once a download is complete, files will be decompressed (if necessary) and moved to downloadDestinationPath - NSString *temporaryFileDownloadPath; - - // If the response is gzipped and shouldWaitToInflateCompressedResponses is NO, a file will be created at this path containing the inflated response as it comes in - NSString *temporaryUncompressedDataDownloadPath; - - // Used for writing data to a file when downloadDestinationPath is set - NSOutputStream *fileDownloadOutputStream; - - NSOutputStream *inflatedFileDownloadOutputStream; - - // When the request fails or completes successfully, complete will be true - BOOL complete; - + BOOL _complete; // external "finished" indicator, subject of KVO notifications; updates after 'complete' BOOL finished; // True if our 'cancel' selector has been called BOOL cancelled; - - // If an error occurs, error will contain an NSError - // If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information - NSError *error; - - // Username and password used for authentication - NSString *username; - NSString *password; - - // User-Agent for this request - NSString *userAgentString; - - // Domain used for NTLM authentication - NSString *domain; - - // Username and password used for proxy authentication - NSString *proxyUsername; - NSString *proxyPassword; - - // Domain used for NTLM proxy authentication - NSString *proxyDomain; - - // Delegate for displaying upload progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself) - id uploadProgressDelegate; - - // Delegate for displaying download progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself) - id downloadProgressDelegate; // Whether we've seen the headers of the response yet BOOL haveExaminedHeaders; - // Data we receive will be stored here. Data may be compressed unless allowCompressedResponse is false - you should use [request responseData] instead in most cases - NSMutableData *rawResponseData; - // Used for sending and receiving data CFHTTPMessageRef request; - NSInputStream *readStream; // Used for authentication CFHTTPAuthenticationRef requestAuthentication; - NSDictionary *requestCredentials; // Used during NTLM authentication int authenticationRetryCount; - // Authentication scheme (Basic, Digest, NTLM) - // If you are using Basic authentication and want to force ASIHTTPRequest to send an authorization header without waiting for a 401, you must set this to (NSString *)kCFHTTPAuthenticationSchemeBasic - NSString *authenticationScheme; - - // Realm for authentication when credentials are required - NSString *authenticationRealm; - // When YES, ASIHTTPRequest will present a dialog allowing users to enter credentials when no-matching credentials were found for a server that requires authentication // The dialog will not be shown if your delegate responds to authenticationNeededForRequest: // Default is NO. BOOL shouldPresentAuthenticationDialog; - // When YES, ASIHTTPRequest will present a dialog allowing users to enter credentials when no-matching credentials were found for a proxy server that requires authentication - // The dialog will not be shown if your delegate responds to proxyAuthenticationNeededForRequest: - // Default is YES (basically, because most people won't want the hassle of adding support for authenticating proxies to their apps) - BOOL shouldPresentProxyAuthenticationDialog; - // Used for proxy authentication CFHTTPAuthenticationRef proxyAuthentication; - NSDictionary *proxyCredentials; // Used during authentication with an NTLM proxy int proxyAuthenticationRetryCount; - // Authentication scheme for the proxy (Basic, Digest, NTLM) - NSString *proxyAuthenticationScheme; - - // Realm for proxy authentication when credentials are required - NSString *proxyAuthenticationRealm; - // HTTP status code, eg: 200 = OK, 404 = Not found etc int responseStatusCode; - // Description of the HTTP status code - NSString *responseStatusMessage; - - // Size of the response - unsigned long long contentLength; - // Size of the partially downloaded content unsigned long long partialDownloadSize; // Size of the POST payload unsigned long long postLength; - // The total amount of downloaded data - unsigned long long totalBytesRead; - - // The total amount of uploaded data - unsigned long long totalBytesSent; - // Last amount of data read (used for incrementing progress) unsigned long long lastBytesRead; // Last amount of data sent (used for incrementing progress) unsigned long long lastBytesSent; - - // This lock prevents the operation from being cancelled at an inopportune moment - NSRecursiveLock *cancelledLock; - - // Called on the delegate (if implemented) when the request starts. Default is requestStarted: - SEL didStartSelector; - - // Called on the delegate (if implemented) when the request receives response headers. Default is request:didReceiveResponseHeaders: - SEL didReceiveResponseHeadersSelector; - - // Called on the delegate (if implemented) when the request receives a Location header and shouldRedirect is YES - // The delegate can then change the url if needed, and can restart the request by calling [request redirectToURL:], or simply cancel it - SEL willRedirectSelector; - - // Called on the delegate (if implemented) when the request completes successfully. Default is requestFinished: - SEL didFinishSelector; - - // Called on the delegate (if implemented) when the request fails. Default is requestFailed: - SEL didFailSelector; - - // Called on the delegate (if implemented) when the request receives data. Default is request:didReceiveData: - // If you set this and implement the method in your delegate, you must handle the data yourself - ASIHTTPRequest will not populate responseData or write the data to downloadDestinationPath - SEL didReceiveDataSelector; - - // Used for recording when something last happened during the request, we will compare this value with the current date to time out requests when appropriate - NSDate *lastActivityTime; - - // Number of seconds to wait before timing out - default is 10 - NSTimeInterval timeOutSeconds; - - // Will be YES when a HEAD request will handle the content-length before this request starts - BOOL shouldResetUploadProgress; - BOOL shouldResetDownloadProgress; - - // Used by HEAD requests when showAccurateProgress is YES to preset the content-length for this request - ASIHTTPRequest *mainRequest; - - // When NO, this request will only update the progress indicator when it completes - // When YES, this request will update the progress indicator according to how much data it has received so far - // The default for requests is YES - // Also see the comments in ASINetworkQueue.h - BOOL showAccurateProgress; - // Used to ensure the progress indicator is only incremented once when showAccurateProgress = NO BOOL updatedProgress; - // Prevents the body of the post being built more than once (largely for subclasses) - BOOL haveBuiltPostBody; - // Used internally, may reflect the size of the internal buffer used by CFNetwork // POST / PUT operations with body sizes greater than uploadBufferSize will not timeout unless more than uploadBufferSize bytes have been sent // Likely to be 32KB on iPhone 3.0, 128KB on Mac OS X Leopard and iPhone 2.2.x unsigned long long uploadBufferSize; - // Text encoding for responses that do not send a Content-Type with a charset value. Defaults to NSISOLatin1StringEncoding - NSStringEncoding defaultResponseEncoding; - // The text encoding of the response, will be defaultResponseEncoding if the server didn't specify. Can't be set. NSStringEncoding responseEncoding; // Tells ASIHTTPRequest not to delete partial downloads, and allows it to use an existing file to resume a download. Defaults to NO. BOOL allowResumeForFileDownloads; - // Custom user information associated with the request (not sent to the server) - NSDictionary *userInfo; NSInteger tag; // Use HTTP 1.0 rather than 1.1 (defaults to false) BOOL useHTTPVersionOne; - // When YES, requests will automatically redirect when they get a HTTP 30x header (defaults to YES) - BOOL shouldRedirect; - - // Used internally to tell the main loop we need to stop and retry with a new url - BOOL needsRedirect; - // Incremented every time this request redirects. When it reaches 5, we give up int redirectCount; - // When NO, requests will not check the secure certificate is valid (use for self-signed certificates during development, DO NOT USE IN PRODUCTION) Default is YES - BOOL validatesSecureCertificate; - // If not nil and the URL scheme is https, CFNetwork configured to supply a client certificate SecIdentityRef clientCertificateIdentity; - NSArray *clientCertificates; - // Details on the proxy to use - you could set these yourself, but it's probably best to let ASIHTTPRequest detect the system proxy settings - NSString *proxyHost; int proxyPort; - // ASIHTTPRequest will assume kCFProxyTypeHTTP if the proxy type could not be automatically determined - // Set to kCFProxyTypeSOCKS if you are manually configuring a SOCKS proxy - NSString *proxyType; - - // URL for a PAC (Proxy Auto Configuration) file. If you want to set this yourself, it's probably best if you use a local file - NSURL *PACurl; - // See ASIAuthenticationState values above. 0 == default == No authentication needed yet ASIAuthenticationState authenticationNeeded; - // When YES, ASIHTTPRequests will present credentials from the session store for requests to the same server before being asked for them - // This avoids an extra round trip for requests after authentication has succeeded, which is much for efficient for authenticated requests with large bodies, or on slower connections - // Set to NO to only present credentials when explicitly asked for them - // This only affects credentials stored in the session cache when useSessionPersistence is YES. Credentials from the keychain are never presented unless the server asks for them - // Default is YES - // For requests using Basic authentication, set authenticationScheme to (NSString *)kCFHTTPAuthenticationSchemeBasic, and credentials can be sent on the very first request when shouldPresentCredentialsBeforeChallenge is YES - BOOL shouldPresentCredentialsBeforeChallenge; - // YES when the request hasn't finished yet. Will still be YES even if the request isn't doing anything (eg it's waiting for delegate authentication). READ-ONLY BOOL inProgress; - // Used internally to track whether the stream is scheduled on the run loop or not - // Bandwidth throttling can unschedule the stream to slow things down while a request is in progress - BOOL readStreamIsScheduled; - // Set to allow a request to automatically retry itself on timeout // Default is zero - timeout will stop the request int numberOfTimesToRetryOnTimeout; @@ -409,30 +175,10 @@ typedef void (^ASIDataBlock)(NSData *data); // Temporarily set to YES when a closed connection forces a retry (internally, this stops ASIHTTPRequest cleaning up a temporary post body) BOOL willRetryRequest; - // When YES, requests will keep the connection to the server alive for a while to allow subsequent requests to re-use it for a substantial speed-boost - // Persistent connections will not be used if the server explicitly closes the connection - // Default is YES - BOOL shouldAttemptPersistentConnection; - - // Number of seconds to keep an inactive persistent connection open on the client side - // Default is 60 - // If we get a keep-alive header, this is this value is replaced with how long the server told us to keep the connection around - // A future date is created from this and used for expiring the connection, this is stored in connectionInfo's expires value - NSTimeInterval persistentConnectionTimeoutSeconds; // Set to yes when an appropriate keep-alive header is found BOOL connectionCanBeReused; - // Stores information about the persistent connection that is currently in use. - // It may contain: - // * The id we set for a particular connection, incremented every time we want to specify that we need a new connection - // * The date that connection should expire - // * A host, port and scheme for the connection. These are used to determine whether that connection can be reused by a subsequent request (all must match the new request) - // * An id for the request that is currently using the connection. This is used for determining if a connection is available or not (we store a number rather than a reference to the request so we don't need to hang onto a request until the connection expires) - // * A reference to the stream that is currently using the connection. This is necessary because we need to keep the old stream open until we've opened a new one. - // The stream will be closed + released either when another request comes to use the connection, or when the timer fires to tell the connection to expire - NSMutableDictionary *connectionInfo; - // When set to YES, 301 and 302 automatic redirects will use the original method and and body, according to the HTTP 1.1 standard // Default is NO (to follow the behaviour of most browsers) BOOL shouldUseRFC2616RedirectBehaviour; @@ -440,18 +186,6 @@ typedef void (^ASIDataBlock)(NSData *data); // Used internally to record when a request has finished downloading data BOOL downloadComplete; - // An ID that uniquely identifies this request - primarily used for debugging persistent connections - NSNumber *requestID; - - // Will be ASIHTTPRequestRunLoopMode for synchronous requests, NSDefaultRunLoopMode for all other requests - NSString *runLoopMode; - - // This timer checks up on the request every 0.25 seconds, and updates progress - NSTimer *statusTimer; - - // The download cache that will be used for this request (use [ASIHTTPRequest setDefaultCache:cache] to configure a default cache - id downloadCache; - // The cache policy that will be used for this request - See ASICacheDelegate.h for possible values ASICachePolicy cachePolicy; @@ -469,26 +203,6 @@ typedef void (^ASIDataBlock)(NSData *data); UIBackgroundTaskIdentifier backgroundTask; #endif - // When downloading a gzipped response, the request will use this helper object to inflate the response - ASIDataDecompressor *dataDecompressor; - - // Controls how responses with a gzipped encoding are inflated (decompressed) - // When set to YES (This is the default): - // * gzipped responses for requests without a downloadDestinationPath will be inflated only when [request responseData] / [request responseString] is called - // * gzipped responses for requests with a downloadDestinationPath set will be inflated only when the request completes - // - // When set to NO - // All requests will inflate the response as it comes in - // * If the request has no downloadDestinationPath set, the raw (compressed) response is discarded and rawResponseData will contain the decompressed response - // * If the request has a downloadDestinationPath, the raw response will be stored in temporaryFileDownloadPath as normal, the inflated response will be stored in temporaryUncompressedDataDownloadPath - // Once the request completes successfully, the contents of temporaryUncompressedDataDownloadPath are moved into downloadDestinationPath - // - // Setting this to NO may be especially useful for users using ASIHTTPRequest in conjunction with a streaming parser, as it will allow partial gzipped responses to be inflated and passed on to the parser while the request is still running - BOOL shouldWaitToInflateCompressedResponses; - - // Will be YES if this is a request created behind the scenes to download a PAC file - these requests do not attempt to configure their own proxies - BOOL isPACFileRequest; - // Used for downloading PAC files from http / https webservers ASIHTTPRequest *PACFileRequest; @@ -543,13 +257,13 @@ typedef void (^ASIDataBlock)(NSData *data); #pragma mark init / dealloc // Should be an HTTP or HTTPS url, may include username and password if appropriate -- (id)initWithURL:(NSURL *)newURL; +- (instancetype)initWithURL:(NSURL *)newURL; // Convenience constructor -+ (id)requestWithURL:(NSURL *)newURL; ++ (instancetype)requestWithURL:(NSURL *)newURL; -+ (id)requestWithURL:(NSURL *)newURL usingCache:(id )cache; -+ (id)requestWithURL:(NSURL *)newURL usingCache:(id )cache andCachePolicy:(ASICachePolicy)policy; ++ (instancetype)requestWithURL:(NSURL *)newURL usingCache:(id )cache; ++ (instancetype)requestWithURL:(NSURL *)newURL usingCache:(id )cache andCachePolicy:(ASICachePolicy)policy; #if NS_BLOCKS_AVAILABLE - (void)setStartedBlock:(ASIBasicBlock)aStartedBlock; @@ -638,10 +352,10 @@ typedef void (^ASIDataBlock)(NSData *data); - (void)incrementUploadSizeBy:(long long)length; // Helper method for interacting with progress indicators to abstract the details of different APIS (NSProgressIndicator and UIProgressView) -+ (void)updateProgressIndicator:(id *)indicator withProgress:(unsigned long long)progress ofTotal:(unsigned long long)total; ++ (void)updateProgressIndicator:(id)indicator withProgress:(unsigned long long)progress ofTotal:(unsigned long long)total; // Helper method used for performing invocations on the main thread (used for progress) -+ (void)performSelector:(SEL)selector onTarget:(id *)target withObject:(id)object amount:(void *)amount callerToRetain:(id)caller; ++ (void)performSelector:(SEL)selector onTarget:(id)target withObject:(id)object amount:(void *)amount callerToRetain:(id)caller; #pragma mark talking to delegates @@ -746,6 +460,8 @@ typedef void (^ASIDataBlock)(NSData *data); // Called automatically when a request is started to clean up any persistent connections that have expired + (void)expirePersistentConnections; ++ (void)clearPersistentConnections; + #pragma mark default time out + (NSTimeInterval)defaultTimeOutSeconds; @@ -901,104 +617,281 @@ typedef void (^ASIDataBlock)(NSData *data); #pragma mark === -@property (atomic, retain) NSString *username; -@property (atomic, retain) NSString *password; +// Username and password used for authentication +@property (atomic, strong) NSString *username; +@property (atomic, strong) NSString *password; + +// User-Agent for this request @property (atomic, retain) NSString *userAgentString; + +// Domain used for NTLM authentication @property (atomic, retain) NSString *domain; +// Username and password used for proxy authentication @property (atomic, retain) NSString *proxyUsername; + +// Username and password used for proxy authentication @property (atomic, retain) NSString *proxyPassword; -@property (atomic, retain) NSString *proxyDomain; +// Domain used for NTLM proxy authentication +@property (retain) NSString *proxyDomain; + +// Details on the proxy to use - you could set these yourself, but it's probably best to let ASIHTTPRequest detect the system proxy settings @property (atomic, retain) NSString *proxyHost; @property (atomic, assign) int proxyPort; + +// ASIHTTPRequest will assume kCFProxyTypeHTTP if the proxy type could not be automatically determined +// Set to kCFProxyTypeSOCKS if you are manually configuring a SOCKS proxy @property (atomic, retain) NSString *proxyType; + +// The url for this operation, should include GET params in the query string where appropriate @property (retain,setter=setURL:, nonatomic) NSURL *url; + +// Will always contain the original url used for making the request (the value of url can change when a request is redirected) @property (atomic, retain) NSURL *originalURL; -@property (assign, nonatomic) id delegate; + +// The delegate - will be notified of various changes in state via the ASIHTTPRequestDelegate protocol +// id +@property (weak, nonatomic) id delegate; + +// Another delegate that is also notified of request status changes and progress updates +// Generally, you won't use this directly, but ASINetworkQueue sets itself as the queue so it can proxy updates to its own delegates +// id @property (retain, nonatomic) id queue; -@property (assign, nonatomic) id uploadProgressDelegate; -@property (assign, nonatomic) id downloadProgressDelegate; + +// NOTE: WILL BE RETAINED BY THE REQUEST + +// Delegate for displaying upload progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself) +// id +@property (weak, nonatomic) id uploadProgressDelegate; + +// Delegate for displaying download progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself) +// id +@property (weak, nonatomic) id downloadProgressDelegate; @property (atomic, assign) BOOL useKeychainPersistence; + +// If useSessionPersistence is true, network requests will save credentials and reuse for the duration of the session (until clearSession is called) @property (atomic, assign) BOOL useSessionPersistence; + +// When downloadDestinationPath is set, the result of this request will be downloaded to the file at this location +// If downloadDestinationPath is not set, download data will be stored in memory @property (atomic, retain) NSString *downloadDestinationPath; + +// The location that files will be downloaded to. Once a download is complete, files will be decompressed (if necessary) and moved to downloadDestinationPath @property (atomic, retain) NSString *temporaryFileDownloadPath; + +// If the response is gzipped and shouldWaitToInflateCompressedResponses is NO, a file will be created at this path containing the inflated response as it comes in @property (atomic, retain) NSString *temporaryUncompressedDataDownloadPath; + +// Called on the delegate (if implemented) when the request starts. Default is requestStarted: @property (atomic, assign) SEL didStartSelector; + +// Called on the delegate (if implemented) when the request receives response headers. Default is request:didReceiveResponseHeaders: @property (atomic, assign) SEL didReceiveResponseHeadersSelector; + +// Called on the delegate (if implemented) when the request receives a Location header and shouldRedirect is YES +// The delegate can then change the url if needed, and can restart the request by calling [request redirectToURL:], or simply cancel it @property (atomic, assign) SEL willRedirectSelector; + +// Called on the delegate (if implemented) when the request completes successfully. Default is requestFinished: @property (atomic, assign) SEL didFinishSelector; + +// Called on the delegate (if implemented) when the request fails. Default is requestFailed: @property (atomic, assign) SEL didFailSelector; + +// Called on the delegate (if implemented) when the request receives data. Default is request:didReceiveData: +// If you set this and implement the method in your delegate, you must handle the data yourself - ASIHTTPRequest will not populate responseData or write the data to downloadDestinationPath @property (atomic, assign) SEL didReceiveDataSelector; + +// Realm for authentication when credentials are required @property (atomic, retain,readonly) NSString *authenticationRealm; -@property (atomic, retain,readonly) NSString *proxyAuthenticationRealm; -@property (atomic, retain) NSError *error; + +// Realm for proxy authentication when credentials are required +@property (atomic, strong,readonly) NSString *proxyAuthenticationRealm; + +// If an error occurs, error will contain an NSError +// If error code is = ASIConnectionFailureErrorType (1, Connection failure occurred) - inspect [[error userInfo] objectForKey:NSUnderlyingErrorKey] for more information +@property (atomic, strong) NSError *error; + +// When the request fails or completes successfully, complete will be true @property (atomic, assign,readonly) BOOL complete; + +// Will be populated with HTTP response headers from the server @property (atomic, retain) NSDictionary *responseHeaders; + +// Dictionary for custom HTTP request headers @property (atomic, retain) NSMutableDictionary *requestHeaders; -@property (atomic, retain) NSMutableArray *requestCookies; + +// Can be used to manually insert cookie headers to a request, but it's more likely that sessionCookies will do this for you +@property (atomic, strong) NSMutableArray *requestCookies; + +// Will be populated with cookies @property (atomic, retain,readonly) NSArray *responseCookies; + +// If use useCookiePersistence is true, network requests will present valid cookies from previous requests @property (atomic, assign) BOOL useCookiePersistence; + +// Used for authentication @property (atomic, retain) NSDictionary *requestCredentials; + +// Used for proxy authentication @property (atomic, retain) NSDictionary *proxyCredentials; @property (atomic, assign,readonly) int responseStatusCode; + +// Description of the HTTP status code @property (atomic, retain,readonly) NSString *responseStatusMessage; + + +// Data we receive will be stored here. Data may be compressed unless allowCompressedResponse is false - you should use [request responseData] instead in most cases @property (atomic, retain) NSMutableData *rawResponseData; + +// Number of seconds to wait before timing out - default is 10 @property (atomic, assign) NSTimeInterval timeOutSeconds; + +// HTTP method to use (eg: GET / POST / PUT / DELETE / HEAD etc). Defaults to GET @property (retain, nonatomic) NSString *requestMethod; -@property (atomic, retain) NSMutableData *postBody; + +// Request body - only used when the whole body is stored in memory (shouldStreamPostDataFromDisk is false) +@property (atomic, strong) NSMutableData *postBody; + +// Size of the response @property (atomic, assign) unsigned long long contentLength; @property (atomic, assign) unsigned long long postLength; + +// Will be YES when a HEAD request will handle the content-length before this request starts @property (atomic, assign) BOOL shouldResetDownloadProgress; @property (atomic, assign) BOOL shouldResetUploadProgress; -@property (atomic, assign) ASIHTTPRequest *mainRequest; + +// Used by HEAD requests when showAccurateProgress is YES to preset the content-length for this request +@property (atomic, weak) ASIHTTPRequest *mainRequest; + +// When NO, this request will only update the progress indicator when it completes +// When YES, this request will update the progress indicator according to how much data it has received so far +// The default for requests is YES +// Also see the comments in ASINetworkQueue.h @property (atomic, assign) BOOL showAccurateProgress; + +// The total amount of downloaded data @property (atomic, assign) unsigned long long totalBytesRead; + +// The total amount of uploaded data @property (atomic, assign) unsigned long long totalBytesSent; + +// Text encoding for responses that do not send a Content-Type with a charset value. Defaults to NSISOLatin1StringEncoding @property (atomic, assign) NSStringEncoding defaultResponseEncoding; @property (atomic, assign) NSStringEncoding responseEncoding; + +// If allowCompressedResponse is true, requests will inform the server they can accept compressed data, and will automatically decompress gzipped responses. Default is true. @property (atomic, assign) BOOL allowCompressedResponse; @property (atomic, assign) BOOL allowResumeForFileDownloads; -@property (atomic, retain) NSDictionary *userInfo; + +// Custom user information associated with the request (not sent to the server) +@property (atomic, strong) NSDictionary *userInfo; @property (atomic, assign) NSInteger tag; -@property (atomic, retain) NSString *postBodyFilePath; + +// Path to file used to store post body (when shouldStreamPostDataFromDisk is true) +// You can set this yourself - useful if you want to PUT a file from local disk +@property (atomic, strong) NSString *postBodyFilePath; + +// When true, post body will be streamed from a file on disk, rather than loaded into memory at once (useful for large uploads) +// Automatically set to true in ASIFormDataRequests when using setFile:forKey: @property (atomic, assign) BOOL shouldStreamPostDataFromDisk; + +// Set to true when ASIHTTPRequest automatically created a temporary file containing the request body (when true, the file at postBodyFilePath will be deleted at the end of the request) @property (atomic, assign) BOOL didCreateTemporaryPostDataFile; @property (atomic, assign) BOOL useHTTPVersionOne; @property (atomic, assign, readonly) unsigned long long partialDownloadSize; + +// When YES, requests will automatically redirect when they get a HTTP 30x header (defaults to YES) @property (atomic, assign) BOOL shouldRedirect; + +// When NO, requests will not check the secure certificate is valid (use for self-signed certificates during development, DO NOT USE IN PRODUCTION) Default is YES @property (atomic, assign) BOOL validatesSecureCertificate; + +// If shouldCompressRequestBody is true, the request body will be gzipped. Default is false. +// You will probably need to enable this feature on your webserver to make this work. Tested with apache only. @property (atomic, assign) BOOL shouldCompressRequestBody; + +// URL for a PAC (Proxy Auto Configuration) file. If you want to set this yourself, it's probably best if you use a local file @property (atomic, retain) NSURL *PACurl; + +// Authentication scheme (Basic, Digest, NTLM) +// If you are using Basic authentication and want to force ASIHTTPRequest to send an authorization header without waiting for a 401, you must set this to (NSString *)kCFHTTPAuthenticationSchemeBasic @property (atomic, retain) NSString *authenticationScheme; + +// Authentication scheme for the proxy (Basic, Digest, NTLM) @property (atomic, retain) NSString *proxyAuthenticationScheme; @property (atomic, assign) BOOL shouldPresentAuthenticationDialog; + +// When YES, ASIHTTPRequest will present a dialog allowing users to enter credentials when no-matching credentials were found for a proxy server that requires authentication +// The dialog will not be shown if your delegate responds to proxyAuthenticationNeededForRequest: +// Default is YES (basically, because most people won't want the hassle of adding support for authenticating proxies to their apps) @property (atomic, assign) BOOL shouldPresentProxyAuthenticationDialog; @property (atomic, assign, readonly) ASIAuthenticationState authenticationNeeded; + +// When YES, ASIHTTPRequests will present credentials from the session store for requests to the same server before being asked for them +// This avoids an extra round trip for requests after authentication has succeeded, which is much for efficient for authenticated requests with large bodies, or on slower connections +// Set to NO to only present credentials when explicitly asked for them +// This only affects credentials stored in the session cache when useSessionPersistence is YES. Credentials from the keychain are never presented unless the server asks for them +// Default is YES +// For requests using Basic authentication, set authenticationScheme to (NSString *)kCFHTTPAuthenticationSchemeBasic, and credentials can be sent on the very first request when shouldPresentCredentialsBeforeChallenge is YES @property (atomic, assign) BOOL shouldPresentCredentialsBeforeChallenge; @property (atomic, assign, readonly) int authenticationRetryCount; @property (atomic, assign, readonly) int proxyAuthenticationRetryCount; @property (atomic, assign) BOOL haveBuiltRequestHeaders; + +// Prevents the body of the post being built more than once (largely for subclasses) @property (assign, nonatomic) BOOL haveBuiltPostBody; @property (atomic, assign, readonly) BOOL inProgress; @property (atomic, assign) int numberOfTimesToRetryOnTimeout; @property (atomic, assign, readonly) int retryCount; + +// When YES, requests will keep the connection to the server alive for a while to allow subsequent requests to re-use it for a substantial speed-boost +// Persistent connections will not be used if the server explicitly closes the connection +// Default is YES @property (atomic, assign) BOOL shouldAttemptPersistentConnection; + +// Number of seconds to keep an inactive persistent connection open on the client side +// Default is 60 +// If we get a keep-alive header, this is this value is replaced with how long the server told us to keep the connection around +// A future date is created from this and used for expiring the connection, this is stored in connectionInfo's expires value @property (atomic, atomic, assign) NSTimeInterval persistentConnectionTimeoutSeconds; @property (atomic, assign) BOOL shouldUseRFC2616RedirectBehaviour; @property (atomic, assign, readonly) BOOL connectionCanBeReused; + +// An ID that uniquely identifies this request - primarily used for debugging persistent connections @property (atomic, retain, readonly) NSNumber *requestID; -@property (atomic, assign) id downloadCache; + +// The download cache that will be used for this request (use [ASIHTTPRequest setDefaultCache:cache] to configure a default cache +// id +@property (atomic, weak) id downloadCache; @property (atomic, assign) ASICachePolicy cachePolicy; @property (atomic, assign) ASICacheStoragePolicy cacheStoragePolicy; @property (atomic, assign, readonly) BOOL didUseCachedResponse; @property (atomic, assign) NSTimeInterval secondsToCache; + +// If not nil and the URL scheme is https, CFNetwork configured to supply a client certificate @property (atomic, retain) NSArray *clientCertificates; #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 @property (atomic, assign) BOOL shouldContinueWhenAppEntersBackground; #endif + +// When downloading a gzipped response, the request will use this helper object to inflate the response @property (atomic, retain) ASIDataDecompressor *dataDecompressor; + +// Controls how responses with a gzipped encoding are inflated (decompressed) +// When set to YES (This is the default): +// * gzipped responses for requests without a downloadDestinationPath will be inflated only when [request responseData] / [request responseString] is called +// * gzipped responses for requests with a downloadDestinationPath set will be inflated only when the request completes +// +// When set to NO +// All requests will inflate the response as it comes in +// * If the request has no downloadDestinationPath set, the raw (compressed) response is discarded and rawResponseData will contain the decompressed response +// * If the request has a downloadDestinationPath, the raw response will be stored in temporaryFileDownloadPath as normal, the inflated response will be stored in temporaryUncompressedDataDownloadPath +// Once the request completes successfully, the contents of temporaryUncompressedDataDownloadPath are moved into downloadDestinationPath +// +// Setting this to NO may be especially useful for users using ASIHTTPRequest in conjunction with a streaming parser, as it will allow partial gzipped responses to be inflated and passed on to the parser while the request is still running @property (atomic, assign) BOOL shouldWaitToInflateCompressedResponses; @end diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m index cb6bbeea..ebf31959 100644 --- a/Classes/ASIHTTPRequest.m +++ b/Classes/ASIHTTPRequest.m @@ -23,6 +23,14 @@ #import "ASIDataDecompressor.h" #import "ASIDataCompressor.h" +#define ASISuppressPerformSelectorLeakWarning(Stuff) \ +do { \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ +Stuff \ +_Pragma("clang diagnostic pop") \ +} while (0) + // Automatically set on build NSString *ASIHTTPRequestVersion = @"v1.8.1-61 2011-09-19"; @@ -51,7 +59,7 @@ static NSTimeInterval defaultTimeOutSeconds = 10; static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventType type, void *clientCallBackInfo) { - [((ASIHTTPRequest*)clientCallBackInfo) handleNetworkEvent: type]; + [((__bridge ASIHTTPRequest*)clientCallBackInfo) handleNetworkEvent: type]; } // This lock prevents the operation from being cancelled while it is trying to update the progress, and vice versa @@ -138,7 +146,13 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy static NSOperationQueue *sharedQueue = nil; // Private stuff -@interface ASIHTTPRequest () +@interface ASIHTTPRequest () { + NSURL *_url; + id _delegate; + id _queue; + + NSString *_requestMethod; +} - (void)cancelLoad; @@ -166,7 +180,7 @@ - (BOOL)shouldTimeOut; - (BOOL)willRedirect; - (BOOL)willAskDelegateToConfirmRedirect; -+ (void)performInvocation:(NSInvocation *)invocation onTarget:(id *)target releasingObject:(id)objectToRelease; ++ (void)performInvocation:(NSInvocation *)invocation onTarget:(id)target releasingObject:(id)objectToRelease; + (void)hideNetworkActivityIndicatorAfterDelay; + (void)hideNetworkActivityIndicatorIfNeeeded; + (void)runRequests; @@ -200,46 +214,93 @@ - (void)callBlock:(ASIBasicBlock)block; - +// When the request fails or completes successfully, complete will be true @property (assign) BOOL complete; -@property (retain) NSArray *responseCookies; -@property (assign) int responseStatusCode; + +// Will be populated with cookies +@property (retain, atomic) NSArray *responseCookies; +@property (assign, atomic) int responseStatusCode; + +// Used for recording when something last happened during the request, we will compare this value with the current date to time out requests when appropriate @property (retain, nonatomic) NSDate *lastActivityTime; -@property (assign) unsigned long long partialDownloadSize; +@property (assign, atomic) unsigned long long partialDownloadSize; @property (assign, nonatomic) unsigned long long uploadBufferSize; -@property (retain, nonatomic) NSOutputStream *postBodyWriteStream; + +// Used when writing to the post body when shouldStreamPostDataFromDisk is true (via appendPostData: or appendPostDataFromFile:) +@property (strong, nonatomic) NSOutputStream *postBodyWriteStream; + +// Used for reading from the post body when sending the request @property (retain, nonatomic) NSInputStream *postBodyReadStream; @property (assign, nonatomic) unsigned long long lastBytesRead; @property (assign, nonatomic) unsigned long long lastBytesSent; + +// This lock prevents the operation from being cancelled at an inopportune moment @property (atomic, retain) NSRecursiveLock *cancelledLock; + +// Used for writing data to a file when downloadDestinationPath is set @property (retain, nonatomic) NSOutputStream *fileDownloadOutputStream; @property (retain, nonatomic) NSOutputStream *inflatedFileDownloadOutputStream; -@property (assign) int authenticationRetryCount; -@property (assign) int proxyAuthenticationRetryCount; + +@property (assign, atomic) int authenticationRetryCount; +@property (assign, atomic) int proxyAuthenticationRetryCount; @property (assign, nonatomic) BOOL updatedProgress; + +// Used internally to tell the main loop we need to stop and retry with a new url @property (assign, nonatomic) BOOL needsRedirect; @property (assign, nonatomic) int redirectCount; -@property (retain, nonatomic) NSData *compressedPostBody; -@property (retain, nonatomic) NSString *compressedPostBodyFilePath; -@property (retain) NSString *authenticationRealm; -@property (retain) NSString *proxyAuthenticationRealm; -@property (retain) NSString *responseStatusMessage; -@property (assign) BOOL inProgress; -@property (assign) int retryCount; + +// gzipped request body used when shouldCompressRequestBody is YES +@property (strong, nonatomic) NSData *compressedPostBody; + +// Path to a temporary file used to store a deflated post body (when shouldCompressPostBody is YES) +@property (strong, nonatomic) NSString *compressedPostBodyFilePath; +@property (retain, atomic) NSString *authenticationRealm; + +// Realm for proxy authentication when credentials are required +@property (strong, atomic) NSString *proxyAuthenticationRealm; + +// Description of the HTTP status code +@property (retain, atomic) NSString *responseStatusMessage; +@property (assign, atomic) BOOL inProgress; +@property (assign, atomic) int retryCount; @property (atomic, assign) BOOL willRetryRequest; -@property (assign) BOOL connectionCanBeReused; +@property (assign, atomic) BOOL connectionCanBeReused; + +// Stores information about the persistent connection that is currently in use. +// It may contain: +// * The id we set for a particular connection, incremented every time we want to specify that we need a new connection +// * The date that connection should expire +// * A host, port and scheme for the connection. These are used to determine whether that connection can be reused by a subsequent request (all must match the new request) +// * An id for the request that is currently using the connection. This is used for determining if a connection is available or not (we store a number rather than a reference to the request so we don't need to hang onto a request until the connection expires) +// * A reference to the stream that is currently using the connection. This is necessary because we need to keep the old stream open until we've opened a new one. +// The stream will be closed + released either when another request comes to use the connection, or when the timer fires to tell the connection to expire @property (retain, nonatomic) NSMutableDictionary *connectionInfo; + +// Used for sending and receiving data @property (retain, nonatomic) NSInputStream *readStream; -@property (assign) ASIAuthenticationState authenticationNeeded; +@property (assign, atomic) ASIAuthenticationState authenticationNeeded; + +// Used internally to track whether the stream is scheduled on the run loop or not +// Bandwidth throttling can unschedule the stream to slow things down while a request is in progress @property (assign, nonatomic) BOOL readStreamIsScheduled; @property (assign, nonatomic) BOOL downloadComplete; -@property (retain) NSNumber *requestID; -@property (assign, nonatomic) NSString *runLoopMode; -@property (retain, nonatomic) NSTimer *statusTimer; -@property (assign) BOOL didUseCachedResponse; + +// An ID that uniquely identifies this request - primarily used for debugging persistent connections +@property (retain, atomic) NSNumber *requestID; + +// Will be ASIHTTPRequestRunLoopMode for synchronous requests, NSDefaultRunLoopMode for all other requests +@property (strong, nonatomic) NSString *runLoopMode; + + +// This timer checks up on the request every 0.25 seconds, and updates progress +@property (strong, nonatomic) NSTimer *statusTimer; +@property (assign, atomic) BOOL didUseCachedResponse; + +// Temporarily stores the url we are about to redirect to. Will be nil again when we do redirect @property (retain, nonatomic) NSURL *redirectURL; +// Will be YES if this is a request created behind the scenes to download a PAC file - these requests do not attempt to configure their own proxies @property (assign, nonatomic) BOOL isPACFileRequest; @property (retain, nonatomic) ASIHTTPRequest *PACFileRequest; @property (retain, nonatomic) NSInputStream *PACFileReadStream; @@ -276,7 +337,7 @@ + (void)initialize } -- (id)initWithURL:(NSURL *)newURL +- (instancetype)initWithURL:(NSURL *)newURL { self = [self init]; [self setRequestMethod:@"GET"]; @@ -298,7 +359,7 @@ - (id)initWithURL:(NSURL *)newURL [self setUseSessionPersistence:YES]; [self setUseCookiePersistence:YES]; [self setValidatesSecureCertificate:YES]; - [self setRequestCookies:[[[NSMutableArray alloc] init] autorelease]]; + [self setRequestCookies:[NSMutableArray array]]; [self setDidStartSelector:@selector(requestStarted:)]; [self setDidReceiveResponseHeadersSelector:@selector(request:didReceiveResponseHeaders:)]; [self setWillRedirectSelector:@selector(request:willRedirectToURL:)]; @@ -306,24 +367,24 @@ - (id)initWithURL:(NSURL *)newURL [self setDidFailSelector:@selector(requestFailed:)]; [self setDidReceiveDataSelector:@selector(request:didReceiveData:)]; [self setURL:newURL]; - [self setCancelledLock:[[[NSRecursiveLock alloc] init] autorelease]]; + [self setCancelledLock:[[NSRecursiveLock alloc] init]]; [self setDownloadCache:[[self class] defaultCache]]; return self; } -+ (id)requestWithURL:(NSURL *)newURL ++ (instancetype)requestWithURL:(NSURL *)newURL { - return [[[self alloc] initWithURL:newURL] autorelease]; + return [[self alloc] initWithURL:newURL]; } -+ (id)requestWithURL:(NSURL *)newURL usingCache:(id )cache ++ (instancetype)requestWithURL:(NSURL *)newURL usingCache:(id )cache { return [self requestWithURL:newURL usingCache:cache andCachePolicy:ASIUseDefaultCachePolicy]; } -+ (id)requestWithURL:(NSURL *)newURL usingCache:(id )cache andCachePolicy:(ASICachePolicy)policy ++ (instancetype)requestWithURL:(NSURL *)newURL usingCache:(id )cache andCachePolicy:(ASICachePolicy)policy { - ASIHTTPRequest *request = [[[self alloc] initWithURL:newURL] autorelease]; + ASIHTTPRequest *request = [[self alloc] initWithURL:newURL]; [request setDownloadCache:cache]; [request setCachePolicy:policy]; return request; @@ -345,60 +406,10 @@ - (void)dealloc CFRelease(clientCertificateIdentity); } [self cancelLoad]; - [redirectURL release]; - [statusTimer invalidate]; - [statusTimer release]; - [queue release]; - [userInfo release]; - [postBody release]; - [compressedPostBody release]; - [error release]; - [requestHeaders release]; - [requestCookies release]; - [downloadDestinationPath release]; - [temporaryFileDownloadPath release]; - [temporaryUncompressedDataDownloadPath release]; - [fileDownloadOutputStream release]; - [inflatedFileDownloadOutputStream release]; - [username release]; - [password release]; - [domain release]; - [authenticationRealm release]; - [authenticationScheme release]; - [requestCredentials release]; - [proxyHost release]; - [proxyType release]; - [proxyUsername release]; - [proxyPassword release]; - [proxyDomain release]; - [proxyAuthenticationRealm release]; - [proxyAuthenticationScheme release]; - [proxyCredentials release]; - [url release]; - [originalURL release]; - [lastActivityTime release]; - [responseCookies release]; - [rawResponseData release]; - [responseHeaders release]; - [requestMethod release]; - [cancelledLock release]; - [postBodyFilePath release]; - [compressedPostBodyFilePath release]; - [postBodyWriteStream release]; - [postBodyReadStream release]; - [PACurl release]; - [clientCertificates release]; - [responseStatusMessage release]; - [connectionInfo release]; - [requestID release]; - [dataDecompressor release]; - [userAgentString release]; - + [_statusTimer invalidate]; #if NS_BLOCKS_AVAILABLE [self releaseBlocksOnMainThread]; #endif - - [super dealloc]; } #if NS_BLOCKS_AVAILABLE @@ -407,62 +418,50 @@ - (void)releaseBlocksOnMainThread NSMutableArray *blocks = [NSMutableArray array]; if (completionBlock) { [blocks addObject:completionBlock]; - [completionBlock release]; completionBlock = nil; } if (failureBlock) { [blocks addObject:failureBlock]; - [failureBlock release]; failureBlock = nil; } if (startedBlock) { [blocks addObject:startedBlock]; - [startedBlock release]; startedBlock = nil; } if (headersReceivedBlock) { [blocks addObject:headersReceivedBlock]; - [headersReceivedBlock release]; headersReceivedBlock = nil; } if (bytesReceivedBlock) { [blocks addObject:bytesReceivedBlock]; - [bytesReceivedBlock release]; bytesReceivedBlock = nil; } if (bytesSentBlock) { [blocks addObject:bytesSentBlock]; - [bytesSentBlock release]; bytesSentBlock = nil; } if (downloadSizeIncrementedBlock) { [blocks addObject:downloadSizeIncrementedBlock]; - [downloadSizeIncrementedBlock release]; downloadSizeIncrementedBlock = nil; } if (uploadSizeIncrementedBlock) { [blocks addObject:uploadSizeIncrementedBlock]; - [uploadSizeIncrementedBlock release]; uploadSizeIncrementedBlock = nil; } if (dataReceivedBlock) { [blocks addObject:dataReceivedBlock]; - [dataReceivedBlock release]; dataReceivedBlock = nil; } if (proxyAuthenticationNeededBlock) { [blocks addObject:proxyAuthenticationNeededBlock]; - [proxyAuthenticationNeededBlock release]; proxyAuthenticationNeededBlock = nil; } if (authenticationNeededBlock) { [blocks addObject:authenticationNeededBlock]; - [authenticationNeededBlock release]; authenticationNeededBlock = nil; } if (requestRedirectedBlock) { [blocks addObject:requestRedirectedBlock]; - [requestRedirectedBlock release]; requestRedirectedBlock = nil; } [[self class] performSelectorOnMainThread:@selector(releaseBlocks:) withObject:blocks waitUntilDone:[NSThread isMainThread]]; @@ -479,10 +478,10 @@ + (void)releaseBlocks:(NSArray *)blocks - (void)addRequestHeader:(NSString *)header value:(NSString *)value { - if (!requestHeaders) { + if (!_requestHeaders) { [self setRequestHeaders:[NSMutableDictionary dictionaryWithCapacity:1]]; } - [requestHeaders setObject:value forKey:header]; + [_requestHeaders setObject:value forKey:header]; } // This function will be called either just before a request starts, or when postLength is needed, whichever comes first @@ -520,9 +519,9 @@ - (void)buildPostBody path = [self postBodyFilePath]; } NSError *err = nil; - [self setPostLength:[[[[[NSFileManager alloc] init] autorelease] attributesOfItemAtPath:path error:&err] fileSize]]; + [self setPostLength:[[[[NSFileManager alloc] init] attributesOfItemAtPath:path error:&err] fileSize]]; if (err) { - [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to get attributes for file at path '%@'",path],NSLocalizedDescriptionKey,error,NSUnderlyingErrorKey,nil]]]; + [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to get attributes for file at path '%@'",path],NSLocalizedDescriptionKey,_error,NSUnderlyingErrorKey,nil]]]; return; } @@ -543,7 +542,7 @@ - (void)buildPostBody } if ([self postLength] > 0) { - if ([requestMethod isEqualToString:@"GET"] || [requestMethod isEqualToString:@"DELETE"] || [requestMethod isEqualToString:@"HEAD"]) { + if ([[self requestMethod] isEqualToString:@"GET"] || [[self requestMethod] isEqualToString:@"DELETE"] || [[self requestMethod] isEqualToString:@"HEAD"]) { [self setRequestMethod:@"POST"]; } [self addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%llu",[self postLength]]]; @@ -561,12 +560,12 @@ - (void)setupPostBody [self setDidCreateTemporaryPostDataFile:YES]; } if (![self postBodyWriteStream]) { - [self setPostBodyWriteStream:[[[NSOutputStream alloc] initToFileAtPath:[self postBodyFilePath] append:NO] autorelease]]; + [self setPostBodyWriteStream:[[NSOutputStream alloc] initToFileAtPath:[self postBodyFilePath] append:NO]]; [[self postBodyWriteStream] open]; } } else { if (![self postBody]) { - [self setPostBody:[[[NSMutableData alloc] init] autorelease]]; + [self setPostBody:[[NSMutableData alloc] init]]; } } } @@ -587,7 +586,7 @@ - (void)appendPostData:(NSData *)data - (void)appendPostDataFromFile:(NSString *)file { [self setupPostBody]; - NSInputStream *stream = [[[NSInputStream alloc] initWithFileAtPath:file] autorelease]; + NSInputStream *stream = [[NSInputStream alloc] initWithFileAtPath:file]; [stream open]; while ([stream hasBytesAvailable]) { @@ -612,7 +611,7 @@ - (void)appendPostDataFromFile:(NSString *)file - (NSString *)requestMethod { [[self cancelledLock] lock]; - NSString *m = requestMethod; + NSString *m = _requestMethod; [[self cancelledLock] unlock]; return m; } @@ -620,10 +619,9 @@ - (NSString *)requestMethod - (void)setRequestMethod:(NSString *)newRequestMethod { [[self cancelledLock] lock]; - if (requestMethod != newRequestMethod) { - [requestMethod release]; - requestMethod = [newRequestMethod retain]; - if ([requestMethod isEqualToString:@"POST"] || [requestMethod isEqualToString:@"PUT"] || [postBody length] || postBodyFilePath) { + if (_requestMethod != newRequestMethod) { + _requestMethod = newRequestMethod; + if ([_requestMethod isEqualToString:@"POST"] || [_requestMethod isEqualToString:@"PUT"] || [_postBody length] || _postBodyFilePath) { [self setShouldAttemptPersistentConnection:NO]; } } @@ -633,7 +631,7 @@ - (void)setRequestMethod:(NSString *)newRequestMethod - (NSURL *)url { [[self cancelledLock] lock]; - NSURL *u = url; + NSURL *u = _url; [[self cancelledLock] unlock]; return u; } @@ -646,8 +644,7 @@ - (void)setURL:(NSURL *)newURL [[self cancelledLock] unlock]; return; } - [url release]; - url = [newURL retain]; + _url = newURL; if (requestAuthentication) { CFRelease(requestAuthentication); requestAuthentication = NULL; @@ -667,7 +664,7 @@ - (void)setURL:(NSURL *)newURL - (id)delegate { [[self cancelledLock] lock]; - id d = delegate; + id d = _delegate; [[self cancelledLock] unlock]; return d; } @@ -675,14 +672,14 @@ - (id)delegate - (void)setDelegate:(id)newDelegate { [[self cancelledLock] lock]; - delegate = newDelegate; + _delegate = newDelegate; [[self cancelledLock] unlock]; } - (id)queue { [[self cancelledLock] lock]; - id q = queue; + id q = _queue; [[self cancelledLock] unlock]; return q; } @@ -691,9 +688,8 @@ - (id)queue - (void)setQueue:(id)newQueue { [[self cancelledLock] lock]; - if (newQueue != queue) { - [queue release]; - queue = [newQueue retain]; + if (newQueue != _queue) { + _queue = newQueue; } [[self cancelledLock] unlock]; } @@ -717,13 +713,13 @@ - (void)cancelOnRequestThread [self setComplete:YES]; [self cancelLoad]; - CFRetain(self); + CFRetain((__bridge CFTypeRef)(self)); [self willChangeValueForKey:@"isCancelled"]; cancelled = YES; [self didChangeValueForKey:@"isCancelled"]; [[self cancelledLock] unlock]; - CFRelease(self); + CFRelease((__bridge CFTypeRef)(self)); } - (void)cancel @@ -770,7 +766,7 @@ - (NSString *)responseString return nil; } - return [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:[self responseEncoding]] autorelease]; + return [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:[self responseEncoding]]; } - (BOOL)isResponseCompressed @@ -802,7 +798,7 @@ - (void)startSynchronous if (![self isCancelled] && ![self complete]) { [self main]; - while (!complete) { + while (![self complete]) { [[NSRunLoop currentRunLoop] runMode:[self runLoopMode] beforeDate:[NSDate distantFuture]]; } } @@ -848,7 +844,7 @@ - (void)main @try { [[self cancelledLock] lock]; - +#ifndef TARGET_IS_EXTENSION #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 if ([ASIHTTPRequest isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) { if (!backgroundTask || backgroundTask == UIBackgroundTaskInvalid) { @@ -867,6 +863,7 @@ - (void)main } } #endif +#endif // A HEAD request generated by an ASINetworkQueue may have set the error already. If so, we should not proceed. @@ -900,7 +897,7 @@ - (void)main } // Create a new HTTP request. - request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)[self requestMethod], (CFURLRef)[self url], [self useHTTPVersionOne] ? kCFHTTPVersion1_0 : kCFHTTPVersion1_1); + request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (__bridge CFStringRef)[self requestMethod], (__bridge CFURLRef)[self url], [self useHTTPVersionOne] ? kCFHTTPVersion1_0 : kCFHTTPVersion1_1); if (!request) { [self failWithError:ASIUnableToCreateRequestError]; return; @@ -949,7 +946,7 @@ - (void)main NSString *header; for (header in [self requestHeaders]) { - CFHTTPMessageSetHeaderFieldValue(request, (CFStringRef)header, (CFStringRef)[[self requestHeaders] objectForKey:header]); + CFHTTPMessageSetHeaderFieldValue(request, (__bridge CFStringRef)header, (__bridge CFStringRef)[[self requestHeaders] objectForKey:header]); } // If we immediately have access to proxy settings, start the request @@ -1003,7 +1000,7 @@ - (void)applyAuthorizationHeader if ([credentials objectForKey:@"Authentication"]) { // If we've already talked to this server and have valid credentials, let's apply them to the request - if (CFHTTPMessageApplyCredentialDictionary(request, (CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) { + if (CFHTTPMessageApplyCredentialDictionary(request, (__bridge CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (__bridge CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) { [self setAuthenticationScheme:[credentials objectForKey:@"AuthenticationScheme"]]; #if DEBUG_HTTP_AUTHENTICATION ASI_DEBUG_LOG(@"[AUTH] Request %@ found cached credentials (%@), will reuse without waiting for an authentication challenge",self,[credentials objectForKey:@"AuthenticationScheme"]); @@ -1033,7 +1030,7 @@ - (void)applyAuthorizationHeader if ([self useSessionPersistence]) { credentials = [self findSessionProxyAuthenticationCredentials]; if (credentials) { - if (!CFHTTPMessageApplyCredentialDictionary(request, (CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) { + if (!CFHTTPMessageApplyCredentialDictionary(request, (__bridge CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (__bridge CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) { [[self class] removeProxyAuthenticationCredentialsFromSessionStore:[credentials objectForKey:@"Credentials"]]; } } @@ -1120,13 +1117,13 @@ - (void)buildRequestHeaders - (void)updatePartialDownloadSize { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; if ([self allowResumeForFileDownloads] && [self downloadDestinationPath] && [self temporaryFileDownloadPath] && [fileManager fileExistsAtPath:[self temporaryFileDownloadPath]]) { NSError *err = nil; [self setPartialDownloadSize:[[fileManager attributesOfItemAtPath:[self temporaryFileDownloadPath] error:&err] fileSize]]; if (err) { - [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to get attributes for file at path '%@'",[self temporaryFileDownloadPath]],NSLocalizedDescriptionKey,error,NSUnderlyingErrorKey,nil]]]; + [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to get attributes for file at path '%@'",[self temporaryFileDownloadPath]],NSLocalizedDescriptionKey,[self error],NSUnderlyingErrorKey,nil]]]; return; } } @@ -1158,7 +1155,7 @@ - (void)startRequest [self setContentLength:0]; [self setResponseHeaders:nil]; if (![self downloadDestinationPath]) { - [self setRawResponseData:[[[NSMutableData alloc] init] autorelease]]; + [self setRawResponseData:[NSMutableData data]]; } @@ -1166,7 +1163,7 @@ - (void)startRequest // Create the stream for the request // - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; [self setReadStreamIsScheduled:NO]; @@ -1175,24 +1172,24 @@ - (void)startRequest // Are we gzipping the request body? if ([self compressedPostBodyFilePath] && [fileManager fileExistsAtPath:[self compressedPostBodyFilePath]]) { - [self setPostBodyReadStream:[ASIInputStream inputStreamWithFileAtPath:[self compressedPostBodyFilePath] request:self]]; + [self setPostBodyReadStream:(NSInputStream *)[ASIInputStream inputStreamWithFileAtPath:[self compressedPostBodyFilePath] request:self]]; } else { - [self setPostBodyReadStream:[ASIInputStream inputStreamWithFileAtPath:[self postBodyFilePath] request:self]]; + [self setPostBodyReadStream:(NSInputStream *)[ASIInputStream inputStreamWithFileAtPath:[self postBodyFilePath] request:self]]; } - [self setReadStream:[NSMakeCollectable(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream])) autorelease]]; + [self setReadStream:(__bridge_transfer id)(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(__bridge CFReadStreamRef)[self postBodyReadStream]))]; } else { // If we have a request body, we'll stream it from memory using our custom stream, so that we can measure bandwidth use and it can be bandwidth-throttled if necessary if ([self postBody] && [[self postBody] length] > 0) { if ([self shouldCompressRequestBody] && [self compressedPostBody]) { - [self setPostBodyReadStream:[ASIInputStream inputStreamWithData:[self compressedPostBody] request:self]]; + [self setPostBodyReadStream:(NSInputStream *)[ASIInputStream inputStreamWithData:[self compressedPostBody] request:self]]; } else if ([self postBody]) { - [self setPostBodyReadStream:[ASIInputStream inputStreamWithData:[self postBody] request:self]]; + [self setPostBodyReadStream:(NSInputStream *)[ASIInputStream inputStreamWithData:[self postBody] request:self]]; } - [self setReadStream:[NSMakeCollectable(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream])) autorelease]]; + [self setReadStream:(__bridge_transfer id)(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(__bridge CFReadStreamRef)[self postBodyReadStream]))]; } else { - [self setReadStream:[NSMakeCollectable(CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request)) autorelease]]; + [self setReadStream:(__bridge_transfer id)(CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request))]; } } @@ -1215,35 +1212,30 @@ - (void)startRequest // see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates, - [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot, [NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain, kCFNull,kCFStreamSSLPeerName, nil]; - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], - kCFStreamPropertySSLSettings, - (CFTypeRef)sslProperties); - [sslProperties release]; - } + CFReadStreamSetProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, (__bridge CFTypeRef)sslProperties); + } // Tell CFNetwork to use a client certificate if (clientCertificateIdentity) { NSMutableDictionary *sslProperties = [NSMutableDictionary dictionaryWithCapacity:1]; - NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[clientCertificates count]+1]; + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[_clientCertificates count]+1]; // The first object in the array is our SecIdentityRef - [certificates addObject:(id)clientCertificateIdentity]; + [certificates addObject:(__bridge id)clientCertificateIdentity]; // If we've added any additional certificates, add them too - for (id cert in clientCertificates) { + for (id cert in _clientCertificates) { [certificates addObject:cert]; } [sslProperties setObject:certificates forKey:(NSString *)kCFStreamSSLCertificates]; - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties); + CFReadStreamSetProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, (__bridge CFTypeRef)(sslProperties)); } } @@ -1274,9 +1266,9 @@ - (void)startRequest NSMutableDictionary *proxyToUse = [NSMutableDictionary dictionaryWithObjectsAndKeys:[self proxyHost],hostKey,[NSNumber numberWithInt:[self proxyPort]],portKey,nil]; if ([[self proxyType] isEqualToString:(NSString *)kCFProxyTypeSOCKS]) { - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySOCKSProxy, proxyToUse); + CFReadStreamSetProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertySOCKSProxy, (__bridge CFTypeRef)(proxyToUse)); } else { - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPProxy, proxyToUse); + CFReadStreamSetProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPProxy, (__bridge CFTypeRef)(proxyToUse)); } } @@ -1338,8 +1330,8 @@ - (void)startRequest } if ([[self connectionInfo] objectForKey:@"stream"]) { - oldStream = [[[self connectionInfo] objectForKey:@"stream"] retain]; - + oldStream = [[self connectionInfo] objectForKey:@"stream"]; + CFRetain((__bridge CFTypeRef)oldStream); } // No free connection was found in the pool matching the server/scheme/port we're connecting to, we'll need to create a new one @@ -1354,13 +1346,13 @@ - (void)startRequest } // If we are retrying this request, it will already have a requestID - if (![self requestID]) { + if ([self requestID] == nil) { nextRequestID++; [self setRequestID:[NSNumber numberWithUnsignedInt:nextRequestID]]; } [[self connectionInfo] setObject:[self requestID] forKey:@"request"]; [[self connectionInfo] setObject:[self readStream] forKey:@"stream"]; - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue); + CFReadStreamSetProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue); #if DEBUG_PERSISTENT_CONNECTIONS ASI_DEBUG_LOG(@"[CONNECTION] Request #%@ will use connection #%i",[self requestID],[[[self connectionInfo] objectForKey:@"id"] intValue]); @@ -1369,9 +1361,8 @@ - (void)startRequest // Tag the stream with an id that tells it which connection to use behind the scenes // See http://lists.apple.com/archives/macnetworkprog/2008/Dec/msg00001.html for details on this approach + CFReadStreamSetProperty((__bridge CFReadStreamRef)[self readStream], CFSTR("ASIStreamID"), (__bridge CFTypeRef)([[self connectionInfo] objectForKey:@"id"])); - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], CFSTR("ASIStreamID"), [[self connectionInfo] objectForKey:@"id"]); - } else { #if DEBUG_PERSISTENT_CONNECTIONS ASI_DEBUG_LOG(@"[CONNECTION] Request %@ will not use a persistent connection",self); @@ -1389,9 +1380,9 @@ - (void)startRequest // Start the HTTP connection - CFStreamClientContext ctxt = {0, self, NULL, NULL, NULL}; - if (CFReadStreamSetClient((CFReadStreamRef)[self readStream], kNetworkEvents, ReadStreamClientCallBack, &ctxt)) { - if (CFReadStreamOpen((CFReadStreamRef)[self readStream])) { + CFStreamClientContext ctxt = {0, (__bridge void *)(self), NULL, NULL, NULL}; + if (CFReadStreamSetClient((__bridge CFReadStreamRef)[self readStream], kNetworkEvents, ReadStreamClientCallBack, &ctxt)) { + if (CFReadStreamOpen((__bridge CFReadStreamRef)[self readStream])) { streamSuccessfullyOpened = YES; } } @@ -1401,7 +1392,7 @@ - (void)startRequest // http://lists.apple.com/archives/Macnetworkprog/2006/Mar/msg00119.html if (oldStream) { [oldStream close]; - [oldStream release]; + CFRelease((__bridge CFTypeRef)oldStream); oldStream = nil; } @@ -1419,10 +1410,10 @@ - (void)startRequest } else { [self incrementUploadSizeBy:1]; } - [ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:0 ofTotal:1]; + [ASIHTTPRequest updateProgressIndicator:_uploadProgressDelegate withProgress:0 ofTotal:1]; } if ([self shouldResetDownloadProgress] && ![self partialDownloadSize]) { - [ASIHTTPRequest updateProgressIndicator:&downloadProgressDelegate withProgress:0 ofTotal:1]; + [ASIHTTPRequest updateProgressIndicator:_downloadProgressDelegate withProgress:0 ofTotal:1]; } } @@ -1435,15 +1426,14 @@ - (void)startRequest - (void)setStatusTimer:(NSTimer *)timer { - CFRetain(self); + CFRetain((__bridge CFTypeRef)(self)); // We must invalidate the old timer here, not before we've created and scheduled a new timer // This is because the timer may be the only thing retaining an asynchronous request - if (statusTimer && timer != statusTimer) { - [statusTimer invalidate]; - [statusTimer release]; + if (_statusTimer && timer != _statusTimer) { + [_statusTimer invalidate]; } - statusTimer = [timer retain]; - CFRelease(self); + _statusTimer = timer; + CFRelease((__bridge CFTypeRef)(self)); } // This gets fired every 1/4 of a second to update the progress and work out if we need to timeout @@ -1481,7 +1471,7 @@ - (void)redirectToURL:(NSURL *)newURL - (BOOL)shouldTimeOut { - NSTimeInterval secondsSinceLastActivity = [[NSDate date] timeIntervalSinceDate:lastActivityTime]; + NSTimeInterval secondsSinceLastActivity = [[NSDate date] timeIntervalSinceDate:_lastActivityTime]; // See if we need to timeout if ([self readStream] && [self readStreamIsScheduled] && [self lastActivityTime] && [self timeOutSeconds] > 0 && secondsSinceLastActivity > [self timeOutSeconds]) { @@ -1518,7 +1508,7 @@ - (void)checkRequestStatus // If we are resuming a download, we may need to update the Range header to take account of data we've just downloaded [self updatePartialDownloadSize]; if ([self partialDownloadSize]) { - CFHTTPMessageSetHeaderFieldValue(request, (CFStringRef)@"Range", (CFStringRef)[NSString stringWithFormat:@"bytes=%llu-",[self partialDownloadSize]]); + CFHTTPMessageSetHeaderFieldValue(request, (__bridge CFStringRef)@"Range", (__bridge CFStringRef)[NSString stringWithFormat:@"bytes=%llu-",[self partialDownloadSize]]); } [self setRetryCount:[self retryCount]+1]; [self unscheduleReadStream]; @@ -1539,15 +1529,15 @@ - (void)checkRequestStatus // If we have a post body if ([self postLength]) { - [self setLastBytesSent:totalBytesSent]; + [self setLastBytesSent:_totalBytesSent]; // Find out how much data we've uploaded so far - [self setTotalBytesSent:[[NSMakeCollectable(CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount)) autorelease] unsignedLongLongValue]]; - if (totalBytesSent > lastBytesSent) { + [self setTotalBytesSent:[(__bridge_transfer id)(CFReadStreamCopyProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount)) unsignedLongLongValue]]; + if (_totalBytesSent > lastBytesSent) { // We've uploaded more data, reset the timeout [self setLastActivityTime:[NSDate date]]; - [ASIHTTPRequest incrementBandwidthUsedInLastSecond:(unsigned long)(totalBytesSent-lastBytesSent)]; + [ASIHTTPRequest incrementBandwidthUsedInLastSecond:(unsigned long)(_totalBytesSent-lastBytesSent)]; #if DEBUG_REQUEST_STATUS if ([self totalBytesSent] == [self postLength]) { @@ -1622,8 +1612,8 @@ - (ASIHTTPRequest *)HEADRequest ASIHTTPRequest *headRequest = [[self class] requestWithURL:[self url]]; // Copy the properties that make sense for a HEAD request - [headRequest setRequestHeaders:[[[self requestHeaders] mutableCopy] autorelease]]; - [headRequest setRequestCookies:[[[self requestCookies] mutableCopy] autorelease]]; + [headRequest setRequestHeaders:[[self requestHeaders] mutableCopy]]; + [headRequest setRequestCookies:[[self requestCookies] mutableCopy]]; [headRequest setUseCookiePersistence:[self useCookiePersistence]]; [headRequest setUseKeychainPersistence:[self useKeychainPersistence]]; [headRequest setUseSessionPersistence:[self useSessionPersistence]]; @@ -1643,7 +1633,7 @@ - (ASIHTTPRequest *)HEADRequest [headRequest setUseHTTPVersionOne:[self useHTTPVersionOne]]; [headRequest setValidatesSecureCertificate:[self validatesSecureCertificate]]; [headRequest setClientCertificateIdentity:clientCertificateIdentity]; - [headRequest setClientCertificates:[[clientCertificates copy] autorelease]]; + [headRequest setClientCertificates:[_clientCertificates copy]]; [headRequest setPACurl:[self PACurl]]; [headRequest setShouldPresentCredentialsBeforeChallenge:[self shouldPresentCredentialsBeforeChallenge]]; [headRequest setNumberOfTimesToRetryOnTimeout:[self numberOfTimesToRetryOnTimeout]]; @@ -1671,44 +1661,28 @@ - (void)updateProgressIndicators } } -- (id)uploadProgressDelegate -{ - [[self cancelledLock] lock]; - id d = [[uploadProgressDelegate retain] autorelease]; - [[self cancelledLock] unlock]; - return d; -} - - (void)setUploadProgressDelegate:(id)newDelegate { [[self cancelledLock] lock]; - uploadProgressDelegate = newDelegate; + _uploadProgressDelegate = newDelegate; #if !TARGET_OS_IPHONE // If the uploadProgressDelegate is an NSProgressIndicator, we set its MaxValue to 1.0 so we can update it as if it were a UIProgressView double max = 1.0; - [ASIHTTPRequest performSelector:@selector(setMaxValue:) onTarget:&uploadProgressDelegate withObject:nil amount:&max callerToRetain:nil]; + [ASIHTTPRequest performSelector:@selector(setMaxValue:) onTarget:&_uploadProgressDelegate withObject:nil amount:&max callerToRetain:nil]; #endif [[self cancelledLock] unlock]; } -- (id)downloadProgressDelegate -{ - [[self cancelledLock] lock]; - id d = [[downloadProgressDelegate retain] autorelease]; - [[self cancelledLock] unlock]; - return d; -} - - (void)setDownloadProgressDelegate:(id)newDelegate { [[self cancelledLock] lock]; - downloadProgressDelegate = newDelegate; + _downloadProgressDelegate = newDelegate; #if !TARGET_OS_IPHONE // If the downloadProgressDelegate is an NSProgressIndicator, we set its MaxValue to 1.0 so we can update it as if it were a UIProgressView double max = 1.0; - [ASIHTTPRequest performSelector:@selector(setMaxValue:) onTarget:&downloadProgressDelegate withObject:nil amount:&max callerToRetain:nil]; + [ASIHTTPRequest performSelector:@selector(setMaxValue:) onTarget:&_downloadProgressDelegate withObject:nil amount:&max callerToRetain:nil]; #endif [[self cancelledLock] unlock]; } @@ -1737,15 +1711,15 @@ - (void)updateDownloadProgress return; } - [ASIHTTPRequest performSelector:@selector(request:didReceiveBytes:) onTarget:&queue withObject:self amount:&value callerToRetain:self]; - [ASIHTTPRequest performSelector:@selector(request:didReceiveBytes:) onTarget:&downloadProgressDelegate withObject:self amount:&value callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:didReceiveBytes:) onTarget:_queue withObject:self amount:&value callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:didReceiveBytes:) onTarget:_downloadProgressDelegate withObject:self amount:&value callerToRetain:self]; - [ASIHTTPRequest updateProgressIndicator:&downloadProgressDelegate withProgress:[self totalBytesRead]+[self partialDownloadSize] ofTotal:[self contentLength]+[self partialDownloadSize]]; + [ASIHTTPRequest updateProgressIndicator:_downloadProgressDelegate withProgress:[self totalBytesRead]+[self partialDownloadSize] ofTotal:[self contentLength]+[self partialDownloadSize]]; #if NS_BLOCKS_AVAILABLE if (bytesReceivedBlock) { unsigned long long totalSize = [self contentLength] + [self partialDownloadSize]; - [self performBlockOnMainThread:^{ if (bytesReceivedBlock) { bytesReceivedBlock(value, totalSize); }}]; + [self performBlockOnMainThread:^{ if (self->bytesReceivedBlock) { self->bytesReceivedBlock(value, totalSize); }}]; } #endif [self setLastBytesRead:bytesReadSoFar]; @@ -1782,14 +1756,14 @@ - (void)updateUploadProgress return; } - [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:&queue withObject:self amount:&value callerToRetain:self]; - [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:&uploadProgressDelegate withObject:self amount:&value callerToRetain:self]; - [ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:[self totalBytesSent]-[self uploadBufferSize] ofTotal:[self postLength]-[self uploadBufferSize]]; + [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:_queue withObject:self amount:&value callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:_uploadProgressDelegate withObject:self amount:&value callerToRetain:self]; + [ASIHTTPRequest updateProgressIndicator:_uploadProgressDelegate withProgress:[self totalBytesSent]-[self uploadBufferSize] ofTotal:[self postLength]-[self uploadBufferSize]]; #if NS_BLOCKS_AVAILABLE if(bytesSentBlock){ unsigned long long totalSize = [self postLength]; - [self performBlockOnMainThread:^{ if (bytesSentBlock) { bytesSentBlock(value, totalSize); }}]; + [self performBlockOnMainThread:^{ if (self->bytesSentBlock) { self->bytesSentBlock(value, totalSize); }}]; } #endif } @@ -1797,24 +1771,24 @@ - (void)updateUploadProgress - (void)incrementDownloadSizeBy:(long long)length { - [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:&queue withObject:self amount:&length callerToRetain:self]; - [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:&downloadProgressDelegate withObject:self amount:&length callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:_queue withObject:self amount:&length callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:_downloadProgressDelegate withObject:self amount:&length callerToRetain:self]; #if NS_BLOCKS_AVAILABLE if(downloadSizeIncrementedBlock){ - [self performBlockOnMainThread:^{ if (downloadSizeIncrementedBlock) { downloadSizeIncrementedBlock(length); }}]; + [self performBlockOnMainThread:^{ if (self->downloadSizeIncrementedBlock) { self->downloadSizeIncrementedBlock(length); }}]; } #endif } - (void)incrementUploadSizeBy:(long long)length { - [ASIHTTPRequest performSelector:@selector(request:incrementUploadSizeBy:) onTarget:&queue withObject:self amount:&length callerToRetain:self]; - [ASIHTTPRequest performSelector:@selector(request:incrementUploadSizeBy:) onTarget:&uploadProgressDelegate withObject:self amount:&length callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:incrementUploadSizeBy:) onTarget:_queue withObject:self amount:&length callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:incrementUploadSizeBy:) onTarget:_uploadProgressDelegate withObject:self amount:&length callerToRetain:self]; #if NS_BLOCKS_AVAILABLE if(uploadSizeIncrementedBlock) { - [self performBlockOnMainThread:^{ if (uploadSizeIncrementedBlock) { uploadSizeIncrementedBlock(length); }}]; + [self performBlockOnMainThread:^{ if (self->uploadSizeIncrementedBlock) { self->uploadSizeIncrementedBlock(length); }}]; } #endif } @@ -1823,14 +1797,14 @@ - (void)incrementUploadSizeBy:(long long)length -(void)removeUploadProgressSoFar { long long progressToRemove = -(long long)[self totalBytesSent]; - [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:&queue withObject:self amount:&progressToRemove callerToRetain:self]; - [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:&uploadProgressDelegate withObject:self amount:&progressToRemove callerToRetain:self]; - [ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:0 ofTotal:[self postLength]]; + [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:_queue withObject:self amount:&progressToRemove callerToRetain:self]; + [ASIHTTPRequest performSelector:@selector(request:didSendBytes:) onTarget:_uploadProgressDelegate withObject:self amount:&progressToRemove callerToRetain:self]; + [ASIHTTPRequest updateProgressIndicator:_uploadProgressDelegate withProgress:0 ofTotal:[self postLength]]; #if NS_BLOCKS_AVAILABLE if(bytesSentBlock){ unsigned long long totalSize = [self postLength]; - [self performBlockOnMainThread:^{ if (bytesSentBlock) { bytesSentBlock((unsigned long long)progressToRemove, totalSize); }}]; + [self performBlockOnMainThread:^{ if (self->bytesSentBlock) { self->bytesSentBlock((unsigned long long)progressToRemove, totalSize); }}]; } #endif } @@ -1838,7 +1812,7 @@ -(void)removeUploadProgressSoFar #if NS_BLOCKS_AVAILABLE - (void)performBlockOnMainThread:(ASIBasicBlock)block { - [self performSelectorOnMainThread:@selector(callBlock:) withObject:[[block copy] autorelease] waitUntilDone:[NSThread isMainThread]]; + [self performSelectorOnMainThread:@selector(callBlock:) withObject:[block copy] waitUntilDone:[NSThread isMainThread]]; } - (void)callBlock:(ASIBasicBlock)block @@ -1848,11 +1822,11 @@ - (void)callBlock:(ASIBasicBlock)block #endif -+ (void)performSelector:(SEL)selector onTarget:(id *)target withObject:(id)object amount:(void *)amount callerToRetain:(id)callerToRetain ++ (void)performSelector:(SEL)selector onTarget:(id)target withObject:(id)object amount:(void *)amount callerToRetain:(id)callerToRetain { - if ([*target respondsToSelector:selector]) { + if ([target respondsToSelector:selector]) { NSMethodSignature *signature = nil; - signature = [*target methodSignatureForSelector:selector]; + signature = [target methodSignatureForSelector:selector]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; [invocation setSelector:selector]; @@ -1881,30 +1855,30 @@ + (void)performSelector:(SEL)selector onTarget:(id *)target withObject:(id)objec [cbInvocation setArgument:&callerToRetain atIndex:4]; } - CFRetain(invocation); + CFRetain((__bridge CFTypeRef)(invocation)); // Used to pass in a request that we must retain until after the call // We're using CFRetain rather than [callerToRetain retain] so things to avoid earthquakes when using garbage collection if (callerToRetain) { - CFRetain(callerToRetain); + CFRetain((__bridge CFTypeRef)(callerToRetain)); } [cbInvocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:[NSThread isMainThread]]; } } -+ (void)performInvocation:(NSInvocation *)invocation onTarget:(id *)target releasingObject:(id)objectToRelease ++ (void)performInvocation:(NSInvocation *)invocation onTarget:(id)target releasingObject:(id)objectToRelease { - if (*target && [*target respondsToSelector:[invocation selector]]) { - [invocation invokeWithTarget:*target]; + if (target && [target respondsToSelector:[invocation selector]]) { + [invocation invokeWithTarget:target]; } - CFRelease(invocation); + CFRelease((__bridge CFTypeRef)(invocation)); if (objectToRelease) { - CFRelease(objectToRelease); + CFRelease((__bridge CFTypeRef)(objectToRelease)); } } -+ (void)updateProgressIndicator:(id *)indicator withProgress:(unsigned long long)progress ofTotal:(unsigned long long)total ++ (void)updateProgressIndicator:(id)indicator withProgress:(unsigned long long)progress ofTotal:(unsigned long long)total { #if TARGET_OS_IPHONE // Cocoa Touch: UIProgressView @@ -1917,7 +1891,7 @@ + (void)updateProgressIndicator:(id *)indicator withProgress:(unsigned long long SEL selector = @selector(setDoubleValue:); #endif - if (![*indicator respondsToSelector:selector]) { + if (![indicator respondsToSelector:selector]) { return; } @@ -1935,16 +1909,18 @@ - (void)requestStarted if ([self error] || [self mainRequest]) { return; } - if (delegate && [delegate respondsToSelector:didStartSelector]) { - [delegate performSelector:didStartSelector withObject:self]; + if ([self delegate] && [[self delegate] respondsToSelector:[self didStartSelector]]) { + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self didStartSelector] withObject:self]; + ); } #if NS_BLOCKS_AVAILABLE if(startedBlock){ startedBlock(); } #endif - if (queue && [queue respondsToSelector:@selector(requestStarted:)]) { - [queue performSelector:@selector(requestStarted:) withObject:self]; + if (_queue && [_queue respondsToSelector:@selector(requestStarted:)]) { + [_queue performSelector:@selector(requestStarted:) withObject:self]; } } @@ -1974,8 +1950,10 @@ - (void)requestReceivedResponseHeaders:(NSMutableDictionary *)newResponseHeaders return; } - if (delegate && [delegate respondsToSelector:didReceiveResponseHeadersSelector]) { - [delegate performSelector:didReceiveResponseHeadersSelector withObject:self withObject:newResponseHeaders]; + if (_delegate && [_delegate respondsToSelector:_didReceiveResponseHeadersSelector]) { + ASISuppressPerformSelectorLeakWarning( + [_delegate performSelector:_didReceiveResponseHeadersSelector withObject:self withObject:newResponseHeaders]; + ); } #if NS_BLOCKS_AVAILABLE @@ -1984,8 +1962,8 @@ - (void)requestReceivedResponseHeaders:(NSMutableDictionary *)newResponseHeaders } #endif - if (queue && [queue respondsToSelector:@selector(request:didReceiveResponseHeaders:)]) { - [queue performSelector:@selector(request:didReceiveResponseHeaders:) withObject:self withObject:newResponseHeaders]; + if (_queue && [_queue respondsToSelector:@selector(request:didReceiveResponseHeaders:)]) { + [_queue performSelector:@selector(request:didReceiveResponseHeaders:) withObject:self withObject:newResponseHeaders]; } } @@ -1995,11 +1973,12 @@ - (void)requestWillRedirectToURL:(NSURL *)newURL if ([self error] || [self mainRequest]) { return; } - if (delegate && [delegate respondsToSelector:willRedirectSelector]) { - [delegate performSelector:willRedirectSelector withObject:self withObject:newURL]; + if (_delegate && [_delegate respondsToSelector:_willRedirectSelector]) { + ASISuppressPerformSelectorLeakWarning([_delegate performSelector:_willRedirectSelector withObject:self withObject:newURL]; + ); } - if (queue && [queue respondsToSelector:@selector(request:willRedirectToURL:)]) { - [queue performSelector:@selector(request:willRedirectToURL:) withObject:self withObject:newURL]; + if (_queue && [_queue respondsToSelector:@selector(request:willRedirectToURL:)]) { + [_queue performSelector:@selector(request:willRedirectToURL:) withObject:self withObject:newURL]; } } @@ -2023,8 +2002,10 @@ - (void)requestFinished /* ALWAYS CALLED ON MAIN THREAD! */ - (void)reportFinished { - if (delegate && [delegate respondsToSelector:didFinishSelector]) { - [delegate performSelector:didFinishSelector withObject:self]; + if (_delegate && [_delegate respondsToSelector:_didFinishSelector]) { + ASISuppressPerformSelectorLeakWarning( + [_delegate performSelector:_didFinishSelector withObject:self]; + ); } #if NS_BLOCKS_AVAILABLE @@ -2033,16 +2014,18 @@ - (void)reportFinished } #endif - if (queue && [queue respondsToSelector:@selector(requestFinished:)]) { - [queue performSelector:@selector(requestFinished:) withObject:self]; + if (_queue && [_queue respondsToSelector:@selector(requestFinished:)]) { + [_queue performSelector:@selector(requestFinished:) withObject:self]; } } /* ALWAYS CALLED ON MAIN THREAD! */ - (void)reportFailure { - if (delegate && [delegate respondsToSelector:didFailSelector]) { - [delegate performSelector:didFailSelector withObject:self]; + if (_delegate && [_delegate respondsToSelector:_didFailSelector]) { + ASISuppressPerformSelectorLeakWarning( + [_delegate performSelector:_didFailSelector withObject:self]; + ); } #if NS_BLOCKS_AVAILABLE @@ -2051,16 +2034,18 @@ - (void)reportFailure } #endif - if (queue && [queue respondsToSelector:@selector(requestFailed:)]) { - [queue performSelector:@selector(requestFailed:) withObject:self]; + if (_queue && [_queue respondsToSelector:@selector(requestFailed:)]) { + [_queue performSelector:@selector(requestFailed:) withObject:self]; } } /* ALWAYS CALLED ON MAIN THREAD! */ - (void)passOnReceivedData:(NSData *)data { - if (delegate && [delegate respondsToSelector:didReceiveDataSelector]) { - [delegate performSelector:didReceiveDataSelector withObject:self withObject:data]; + if (_delegate && [_delegate respondsToSelector:_didReceiveDataSelector]) { + ASISuppressPerformSelectorLeakWarning( + [_delegate performSelector:_didReceiveDataSelector withObject:self withObject:data]; + ); } #if NS_BLOCKS_AVAILABLE @@ -2138,7 +2123,7 @@ - (void)readResponseHeaders { [self setAuthenticationNeeded:ASINoAuthenticationNeededYet]; - CFHTTPMessageRef message = (CFHTTPMessageRef)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPResponseHeader); + CFHTTPMessageRef message = (CFHTTPMessageRef)CFReadStreamCopyProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPResponseHeader); if (!message) { return; } @@ -2155,9 +2140,9 @@ - (void)readResponseHeaders } #endif - [self setResponseHeaders:[NSMakeCollectable(CFHTTPMessageCopyAllHeaderFields(message)) autorelease]]; + [self setResponseHeaders:(__bridge_transfer NSDictionary *)(CFHTTPMessageCopyAllHeaderFields(message))]; [self setResponseStatusCode:(int)CFHTTPMessageGetResponseStatusCode(message)]; - [self setResponseStatusMessage:[NSMakeCollectable(CFHTTPMessageCopyResponseStatusLine(message)) autorelease]]; + [self setResponseStatusMessage:(__bridge_transfer NSString *)(CFHTTPMessageCopyResponseStatusLine(message))]; if ([self downloadCache] && ([[self downloadCache] canUseCachedDataForRequest:self])) { @@ -2229,7 +2214,7 @@ - (void)readResponseHeaders // Do we need to redirect? if (![self willRedirect]) { // See if we got a Content-length header - NSString *cLength = [responseHeaders valueForKey:@"Content-Length"]; + NSString *cLength = [[self responseHeaders] valueForKey:@"Content-Length"]; ASIHTTPRequest *theRequest = self; if ([self mainRequest]) { theRequest = [self mainRequest]; @@ -2261,7 +2246,7 @@ - (void)readResponseHeaders NSString *connectionHeader = [[[self responseHeaders] objectForKey:@"Connection"] lowercaseString]; - NSString *httpVersion = [NSMakeCollectable(CFHTTPMessageCopyVersion(message)) autorelease]; + NSString *httpVersion = (__bridge_transfer NSString *)(CFHTTPMessageCopyVersion(message)); // Don't re-use the connection if the server is HTTP 1.0 and didn't send Connection: Keep-Alive if (![httpVersion isEqualToString:(NSString *)kCFHTTPVersion1_0] || [connectionHeader isEqualToString:@"keep-alive"]) { @@ -2301,13 +2286,13 @@ - (void)readResponseHeaders } CFRelease(message); - [self performSelectorOnMainThread:@selector(requestReceivedResponseHeaders:) withObject:[[[self responseHeaders] copy] autorelease] waitUntilDone:[NSThread isMainThread]]; + [self performSelectorOnMainThread:@selector(requestReceivedResponseHeaders:) withObject:[[self responseHeaders] copy] waitUntilDone:[NSThread isMainThread]]; } - (BOOL)willRedirect { // Do we need to redirect? - if (![self shouldRedirect] || ![responseHeaders valueForKey:@"Location"]) { + if (![self shouldRedirect] || ![[self responseHeaders] valueForKey:@"Location"]) { return NO; } @@ -2348,7 +2333,7 @@ - (BOOL)willRedirect } // Force the redirected request to rebuild the request headers (if not a 303, it will re-use old ones, and add any new ones) - [self setRedirectURL:[[NSURL URLWithString:[responseHeaders valueForKey:@"Location"] relativeToURL:[self url]] absoluteURL]]; + [self setRedirectURL:[[NSURL URLWithString:[[self responseHeaders] valueForKey:@"Location"] relativeToURL:[self url]] absoluteURL]]; [self setNeedsRedirect:YES]; // Clear the request cookies @@ -2403,15 +2388,15 @@ - (BOOL)applyProxyCredentials:(NSDictionary *)newCredentials if (newCredentials && proxyAuthentication && request) { // Apply whatever credentials we've built up to the old request - if (CFHTTPMessageApplyCredentialDictionary(request, proxyAuthentication, (CFMutableDictionaryRef)newCredentials, NULL)) { + if (CFHTTPMessageApplyCredentialDictionary(request, proxyAuthentication, (__bridge CFMutableDictionaryRef)newCredentials, NULL)) { //If we have credentials and they're ok, let's save them to the keychain if (useKeychainPersistence) { [self saveProxyCredentialsToKeychain:newCredentials]; } - if (useSessionPersistence) { + if ([self useSessionPersistence]) { NSMutableDictionary *sessionProxyCredentials = [NSMutableDictionary dictionary]; - [sessionProxyCredentials setObject:(id)proxyAuthentication forKey:@"Authentication"]; + [sessionProxyCredentials setObject:(__bridge id)proxyAuthentication forKey:@"Authentication"]; [sessionProxyCredentials setObject:newCredentials forKey:@"Credentials"]; [sessionProxyCredentials setObject:[self proxyHost] forKey:@"Host"]; [sessionProxyCredentials setObject:[NSNumber numberWithInt:[self proxyPort]] forKey:@"Port"]; @@ -2433,16 +2418,16 @@ - (BOOL)applyCredentials:(NSDictionary *)newCredentials if (newCredentials && requestAuthentication && request) { // Apply whatever credentials we've built up to the old request - if (CFHTTPMessageApplyCredentialDictionary(request, requestAuthentication, (CFMutableDictionaryRef)newCredentials, NULL)) { + if (CFHTTPMessageApplyCredentialDictionary(request, requestAuthentication, (__bridge CFMutableDictionaryRef)newCredentials, NULL)) { //If we have credentials and they're ok, let's save them to the keychain if (useKeychainPersistence) { [self saveCredentialsToKeychain:newCredentials]; } - if (useSessionPersistence) { + if ([self useSessionPersistence]) { NSMutableDictionary *sessionCredentials = [NSMutableDictionary dictionary]; - [sessionCredentials setObject:(id)requestAuthentication forKey:@"Authentication"]; + [sessionCredentials setObject:(__bridge id)requestAuthentication forKey:@"Authentication"]; [sessionCredentials setObject:newCredentials forKey:@"Credentials"]; [sessionCredentials setObject:[self url] forKey:@"URL"]; [sessionCredentials setObject:[self authenticationScheme] forKey:@"AuthenticationScheme"]; @@ -2463,7 +2448,7 @@ - (BOOL)applyCredentials:(NSDictionary *)newCredentials - (NSMutableDictionary *)findProxyCredentials { - NSMutableDictionary *newCredentials = [[[NSMutableDictionary alloc] init] autorelease]; + NSMutableDictionary *newCredentials = [[NSMutableDictionary alloc] init]; NSString *user = nil; NSString *pass = nil; @@ -2537,7 +2522,7 @@ - (NSMutableDictionary *)findProxyCredentials - (NSMutableDictionary *)findCredentials { - NSMutableDictionary *newCredentials = [[[NSMutableDictionary alloc] init] autorelease]; + NSMutableDictionary *newCredentials = [[NSMutableDictionary alloc] init]; // First, let's look at the url to see if the username and password were included NSString *user = [[self url] user]; @@ -2769,10 +2754,10 @@ - (void)attemptToApplyProxyCredentialsAndResume // Read authentication data if (!proxyAuthentication) { - CFHTTPMessageRef responseHeader = (CFHTTPMessageRef) CFReadStreamCopyProperty((CFReadStreamRef)[self readStream],kCFStreamPropertyHTTPResponseHeader); + CFHTTPMessageRef responseHeader = (CFHTTPMessageRef) CFReadStreamCopyProperty((__bridge CFReadStreamRef)[self readStream],kCFStreamPropertyHTTPResponseHeader); proxyAuthentication = CFHTTPAuthenticationCreateFromResponse(NULL, responseHeader); CFRelease(responseHeader); - [self setProxyAuthenticationScheme:[NSMakeCollectable(CFHTTPAuthenticationCopyMethod(proxyAuthentication)) autorelease]]; + [self setProxyAuthenticationScheme:(__bridge_transfer NSString *)(CFHTTPAuthenticationCopyMethod(proxyAuthentication))]; } // If we haven't got a CFHTTPAuthenticationRef by now, something is badly wrong, so we'll have to give up @@ -2785,7 +2770,7 @@ - (void)attemptToApplyProxyCredentialsAndResume // Get the authentication realm [self setProxyAuthenticationRealm:nil]; if (!CFHTTPAuthenticationRequiresAccountDomain(proxyAuthentication)) { - [self setProxyAuthenticationRealm:[NSMakeCollectable(CFHTTPAuthenticationCopyRealm(proxyAuthentication)) autorelease]]; + [self setProxyAuthenticationRealm:(__bridge_transfer NSString *)(CFHTTPAuthenticationCopyRealm(proxyAuthentication))]; } // See if authentication is valid @@ -2802,7 +2787,7 @@ - (void)attemptToApplyProxyCredentialsAndResume [delegateAuthenticationLock lock]; // We know the credentials we just presented are bad, we should remove them from the session store too - [[self class] removeProxyAuthenticationCredentialsFromSessionStore:proxyCredentials]; + [[self class] removeProxyAuthenticationCredentialsFromSessionStore:_proxyCredentials]; [self setProxyCredentials:nil]; @@ -2844,10 +2829,10 @@ - (void)attemptToApplyProxyCredentialsAndResume [self cancelLoad]; - if (proxyCredentials) { + if (_proxyCredentials) { // We use startRequest rather than starting all over again in load request because NTLM requires we reuse the request - if ((([self proxyAuthenticationScheme] != (NSString *)kCFHTTPAuthenticationSchemeNTLM) || [self proxyAuthenticationRetryCount] < 2) && [self applyProxyCredentials:proxyCredentials]) { + if ((([self proxyAuthenticationScheme] != (NSString *)kCFHTTPAuthenticationSchemeNTLM) || [self proxyAuthenticationRetryCount] < 2) && [self applyProxyCredentials:_proxyCredentials]) { [self startRequest]; // We've failed NTLM authentication twice, we should assume our credentials are wrong @@ -2946,10 +2931,10 @@ - (void)attemptToApplyCredentialsAndResume // Read authentication data if (!requestAuthentication) { - CFHTTPMessageRef responseHeader = (CFHTTPMessageRef) CFReadStreamCopyProperty((CFReadStreamRef)[self readStream],kCFStreamPropertyHTTPResponseHeader); + CFHTTPMessageRef responseHeader = (CFHTTPMessageRef) CFReadStreamCopyProperty((__bridge CFReadStreamRef)[self readStream],kCFStreamPropertyHTTPResponseHeader); requestAuthentication = CFHTTPAuthenticationCreateFromResponse(NULL, responseHeader); CFRelease(responseHeader); - [self setAuthenticationScheme:[NSMakeCollectable(CFHTTPAuthenticationCopyMethod(requestAuthentication)) autorelease]]; + [self setAuthenticationScheme:(__bridge_transfer NSString *)(CFHTTPAuthenticationCopyMethod(requestAuthentication))]; } if (!requestAuthentication) { @@ -2965,7 +2950,7 @@ - (void)attemptToApplyCredentialsAndResume // Get the authentication realm [self setAuthenticationRealm:nil]; if (!CFHTTPAuthenticationRequiresAccountDomain(requestAuthentication)) { - [self setAuthenticationRealm:[NSMakeCollectable(CFHTTPAuthenticationCopyRealm(requestAuthentication)) autorelease]]; + [self setAuthenticationRealm:(__bridge_transfer NSString *)(CFHTTPAuthenticationCopyRealm(requestAuthentication))]; } #if DEBUG_HTTP_AUTHENTICATION @@ -3000,7 +2985,7 @@ - (void)attemptToApplyCredentialsAndResume [delegateAuthenticationLock lock]; // We know the credentials we just presented are bad, we should remove them from the session store too - [[self class] removeAuthenticationCredentialsFromSessionStore:requestCredentials]; + [[self class] removeAuthenticationCredentialsFromSessionStore:_requestCredentials]; [self setRequestCredentials:nil]; // If the user cancelled authentication via a dialog presented by another request, our queue may have cancelled us @@ -3063,9 +3048,9 @@ - (void)attemptToApplyCredentialsAndResume [self cancelLoad]; - if (requestCredentials) { + if (_requestCredentials) { - if ((([self authenticationScheme] != (NSString *)kCFHTTPAuthenticationSchemeNTLM) || [self authenticationRetryCount] < 2) && [self applyCredentials:requestCredentials]) { + if ((([self authenticationScheme] != (NSString *)kCFHTTPAuthenticationSchemeNTLM) || [self authenticationRetryCount] < 2) && [self applyCredentials:_requestCredentials]) { [self startRequest]; // We've failed NTLM authentication twice, we should assume our credentials are wrong @@ -3176,17 +3161,15 @@ - (void)addBasicAuthenticationHeaderWithUsername:(NSString *)theUsername andPass - (void)handleNetworkEvent:(CFStreamEventType)type { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - + @autoreleasepool { [[self cancelledLock] lock]; if ([self complete] || [self isCancelled]) { [[self cancelledLock] unlock]; - [pool drain]; return; } - CFRetain(self); + CFRetain((__bridge CFTypeRef)(self)); // Dispatch the stream events. switch (type) { @@ -3218,8 +3201,8 @@ - (void)handleNetworkEvent:(CFStreamEventType)type [self attemptToApplyCredentialsAndResume]; } - CFRelease(self); - [pool drain]; + CFRelease((__bridge CFTypeRef)(self)); + } } - (BOOL)willAskDelegateToConfirmRedirect @@ -3235,7 +3218,7 @@ - (BOOL)willAskDelegateToConfirmRedirect // Either the delegate or the queue's delegate is interested in being told when we are about to redirect if (needToAskDelegateAboutRedirect) { - NSURL *newURL = [[[self redirectURL] copy] autorelease]; + NSURL *newURL = [[self redirectURL] copy]; [self setRedirectURL:nil]; [self performSelectorOnMainThread:@selector(requestWillRedirectToURL:) withObject:newURL waitUntilDone:[NSThread isMainThread]]; return true; @@ -3257,14 +3240,14 @@ - (void)handleBytesAvailable // In certain (presumably very rare) circumstances, handleBytesAvailable seems to be called when there isn't actually any data available // We'll check that there is actually data available to prevent blocking on CFReadStreamRead() // So far, I've only seen this in the stress tests, so it might never happen in real-world situations. - if (!CFReadStreamHasBytesAvailable((CFReadStreamRef)[self readStream])) { + if (!CFReadStreamHasBytesAvailable((__bridge CFReadStreamRef)[self readStream])) { return; } long long bufferSize = 16384; - if (contentLength > 262144) { + if (_contentLength > 262144) { bufferSize = 262144; - } else if (contentLength > 65536) { + } else if (_contentLength > 65536) { bufferSize = 65536; } @@ -3360,7 +3343,7 @@ - (void)handleBytesAvailable } } - [self setFileDownloadOutputStream:[[[NSOutputStream alloc] initToFileAtPath:[self temporaryFileDownloadPath] append:append] autorelease]]; + [self setFileDownloadOutputStream:[[NSOutputStream alloc] initToFileAtPath:[self temporaryFileDownloadPath] append:append]]; [[self fileDownloadOutputStream] open]; } @@ -3373,7 +3356,7 @@ - (void)handleBytesAvailable [self setTemporaryUncompressedDataDownloadPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]]; } - [self setInflatedFileDownloadOutputStream:[[[NSOutputStream alloc] initToFileAtPath:[self temporaryUncompressedDataDownloadPath] append:append] autorelease]]; + [self setInflatedFileDownloadOutputStream:[[NSOutputStream alloc] initToFileAtPath:[self temporaryUncompressedDataDownloadPath] append:append]]; [[self inflatedFileDownloadOutputStream] open]; } @@ -3384,9 +3367,9 @@ - (void)handleBytesAvailable //Otherwise, let's add the data to our in-memory store } else { if ([self isResponseCompressed] && ![self shouldWaitToInflateCompressedResponses]) { - [rawResponseData appendData:inflatedData]; + [_rawResponseData appendData:inflatedData]; } else { - [rawResponseData appendBytes:buffer length:(NSUInteger)bytesRead]; + [_rawResponseData appendBytes:buffer length:(NSUInteger)bytesRead]; } } } @@ -3407,8 +3390,8 @@ - (void)handleStreamComplete [progressLock lock]; // Find out how much data we've uploaded so far - [self setLastBytesSent:totalBytesSent]; - [self setTotalBytesSent:[[NSMakeCollectable(CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount)) autorelease] unsignedLongLongValue]]; + [self setLastBytesSent:_totalBytesSent]; + [self setTotalBytesSent:[(__bridge_transfer id)(CFReadStreamCopyProperty((__bridge CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount)) unsignedLongLongValue]]; [self setComplete:YES]; if (![self contentLength]) { [self setContentLength:[self totalBytesRead]]; @@ -3450,7 +3433,7 @@ - (void)handleStreamComplete // Response should already have been inflated, move the temporary file to the destination path } else { NSError *moveError = nil; - [[[[NSFileManager alloc] init] autorelease] moveItemAtPath:[self temporaryUncompressedDataDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; + [[[NSFileManager alloc] init] moveItemAtPath:[self temporaryUncompressedDataDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; if (moveError) { fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]]; } @@ -3470,7 +3453,7 @@ - (void)handleStreamComplete //Move the temporary file to the destination path if (!fileError) { - [[[[NSFileManager alloc] init] autorelease] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; + [[[NSFileManager alloc] init] moveItemAtPath:[self temporaryFileDownloadPath] toPath:[self downloadDestinationPath] error:&moveError]; if (moveError) { fileError = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASIFileManagementError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to move file from '%@' to '%@'",[self temporaryFileDownloadPath],[self downloadDestinationPath]],NSLocalizedDescriptionKey,moveError,NSUnderlyingErrorKey,nil]]; } @@ -3526,7 +3509,7 @@ - (void)handleStreamComplete - (void)markAsFinished { // Autoreleased requests may well be dealloced here otherwise - CFRetain(self); + CFRetain((__bridge CFTypeRef)(self)); // dealloc won't be called when running with GC, so we'll clean these up now if (request) { @@ -3557,7 +3540,7 @@ - (void)markAsFinished [self didChangeValueForKey:@"isExecuting"]; if (!wasFinished) [self didChangeValueForKey:@"isFinished"]; - +#ifndef TARGET_IS_EXTENSION #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 if ([ASIHTTPRequest isMultitaskingSupported] && [self shouldContinueWhenAppEntersBackground]) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -3568,7 +3551,8 @@ - (void)markAsFinished }); } #endif - CFRelease(self); +#endif + CFRelease((__bridge CFTypeRef)(self)); } - (void)useDataFromCache @@ -3653,7 +3637,7 @@ - (BOOL)retryUsingNewConnection - (void)handleStreamError { - NSError *underlyingError = [NSMakeCollectable(CFReadStreamCopyError((CFReadStreamRef)[self readStream])) autorelease]; + NSError *underlyingError = (__bridge_transfer NSError *)(CFReadStreamCopyError((__bridge CFReadStreamRef)[self readStream])); if (![self error]) { // We may already have handled this error @@ -3714,8 +3698,8 @@ - (void)scheduleReadStream // Reset the timeout [self setLastActivityTime:[NSDate date]]; - CFStreamClientContext ctxt = {0, self, NULL, NULL, NULL}; - CFReadStreamSetClient((CFReadStreamRef)[self readStream], kNetworkEvents, ReadStreamClientCallBack, &ctxt); + CFStreamClientContext ctxt = {0, (__bridge void *)(self), NULL, NULL, NULL}; + CFReadStreamSetClient((__bridge CFReadStreamRef)[self readStream], kNetworkEvents, ReadStreamClientCallBack, &ctxt); [[self readStream] scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:[self runLoopMode]]; [self setReadStreamIsScheduled:YES]; } @@ -3737,7 +3721,7 @@ - (void)unscheduleReadStream } [connectionsLock unlock]; - CFReadStreamSetClient((CFReadStreamRef)[self readStream], kCFStreamEventNone, NULL, NULL); + CFReadStreamSetClient((__bridge CFReadStreamRef)[self readStream], kCFStreamEventNone, NULL, NULL); [[self readStream] removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:[self runLoopMode]]; [self setReadStreamIsScheduled:NO]; } @@ -3795,7 +3779,7 @@ - (BOOL)removeTemporaryCompressedUploadFile + (BOOL)removeFileAtPath:(NSString *)path error:(NSError **)err { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; if ([fileManager fileExistsAtPath:path]) { NSError *removeError = nil; @@ -3831,12 +3815,12 @@ - (BOOL)configureProxies } else { #if TARGET_OS_IPHONE - NSDictionary *proxySettings = [NSMakeCollectable(CFNetworkCopySystemProxySettings()) autorelease]; + NSDictionary *proxySettings = (__bridge_transfer NSDictionary *)(CFNetworkCopySystemProxySettings()); #else NSDictionary *proxySettings = [NSMakeCollectable(SCDynamicStoreCopyProxies(NULL)) autorelease]; #endif - proxies = [NSMakeCollectable(CFNetworkCopyProxiesForURL((CFURLRef)[self url], (CFDictionaryRef)proxySettings)) autorelease]; + proxies = (__bridge_transfer NSArray *)(CFNetworkCopyProxiesForURL((__bridge CFURLRef)[self url], (__bridge CFDictionaryRef)proxySettings)); // Now check to see if the proxy settings contained a PAC url, we need to run the script to get the real list of proxies if so NSDictionary *settings = [proxies objectAtIndex:0]; @@ -3872,7 +3856,7 @@ - (void)fetchPACFile { // For file:// urls, we'll use an async NSInputStream (ASIHTTPRequest does not support file:// urls) if ([[self PACurl] isFileURL]) { - NSInputStream *stream = [[[NSInputStream alloc] initWithFileAtPath:[[self PACurl] path]] autorelease]; + NSInputStream *stream = [[NSInputStream alloc] initWithFileAtPath:[[self PACurl] path]]; [self setPACFileReadStream:stream]; [stream setDelegate:(id)self]; [stream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:[self runLoopMode]]; @@ -3959,7 +3943,7 @@ - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode static NSStringEncoding encodingsToTry[2] = {NSUTF8StringEncoding,NSISOLatin1StringEncoding}; NSUInteger i; for (i=0; i<2; i++) { - NSString *pacScript = [[[NSString alloc] initWithBytes:[[self PACFileData] bytes] length:[[self PACFileData] length] encoding:encodingsToTry[i]] autorelease]; + NSString *pacScript = [[NSString alloc] initWithBytes:[[self PACFileData] bytes] length:[[self PACFileData] length] encoding:encodingsToTry[i]]; if (pacScript) { [self runPACScript:pacScript]; break; @@ -3985,11 +3969,16 @@ - (void)runPACScript:(NSString *)script // Work around . This dummy call to // CFNetworkCopyProxiesForURL initialise some state within CFNetwork // that is required by CFNetworkCopyProxiesForAutoConfigurationScript. - CFRelease(CFNetworkCopyProxiesForURL((CFURLRef)[self url], NULL)); +#if TARGET_OS_IPHONE + NSDictionary *proxySettings = (__bridge_transfer NSDictionary *)(CFNetworkCopySystemProxySettings()); +#else + NSDictionary *proxySettings = [NSMakeCollectable(SCDynamicStoreCopyProxies(NULL)) autorelease]; +#endif + CFRelease(CFNetworkCopyProxiesForURL((__bridge CFURLRef)[self url], (__bridge CFDictionaryRef)proxySettings)); // Obtain the list of proxies by running the autoconfiguration script CFErrorRef err = NULL; - NSArray *proxies = [NSMakeCollectable(CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)script,(CFURLRef)[self url], &err)) autorelease]; + NSArray *proxies = (__bridge_transfer NSArray *)(CFNetworkCopyProxiesForAutoConfigurationScript((__bridge CFStringRef)script,(__bridge CFURLRef)[self url], &err)); if (!err && [proxies count] > 0) { NSDictionary *settings = [proxies objectAtIndex:0]; [self setProxyHost:[settings objectForKey:(NSString *)kCFProxyHostNameKey]]; @@ -4047,6 +4036,27 @@ + (void)expirePersistentConnections [connectionsLock unlock]; } ++ (void)clearPersistentConnections +{ + [connectionsLock lock]; + NSUInteger i; + for (i=0; i<[persistentConnectionsPool count]; i++) { + NSDictionary *existingConnection = [persistentConnectionsPool objectAtIndex:i]; + if (![existingConnection objectForKey:@"request"]) { +#if DEBUG_PERSISTENT_CONNECTIONS + ASI_DEBUG_LOG(@"[CONNECTION] Closing connection #%i manualy",[[existingConnection objectForKey:@"id"] intValue]); +#endif + NSInputStream *stream = [existingConnection objectForKey:@"stream"]; + if (stream) { + [stream close]; + } + [persistentConnectionsPool removeObject:existingConnection]; + i--; + } + } + [connectionsLock unlock]; +} + #pragma mark NSCopying - (id)copyWithZone:(NSZone *)zone { @@ -4057,8 +4067,8 @@ - (id)copyWithZone:(NSZone *)zone [newRequest setPostBody:[self postBody]]; [newRequest setShouldStreamPostDataFromDisk:[self shouldStreamPostDataFromDisk]]; [newRequest setPostBodyFilePath:[self postBodyFilePath]]; - [newRequest setRequestHeaders:[[[self requestHeaders] mutableCopyWithZone:zone] autorelease]]; - [newRequest setRequestCookies:[[[self requestCookies] mutableCopyWithZone:zone] autorelease]]; + [newRequest setRequestHeaders:[[self requestHeaders] mutableCopyWithZone:zone]]; + [newRequest setRequestCookies:[[self requestCookies] mutableCopyWithZone:zone]]; [newRequest setUseCookiePersistence:[self useCookiePersistence]]; [newRequest setUseKeychainPersistence:[self useKeychainPersistence]]; [newRequest setUseSessionPersistence:[self useSessionPersistence]]; @@ -4089,13 +4099,13 @@ - (id)copyWithZone:(NSZone *)zone [newRequest setShowAccurateProgress:[self showAccurateProgress]]; [newRequest setDefaultResponseEncoding:[self defaultResponseEncoding]]; [newRequest setAllowResumeForFileDownloads:[self allowResumeForFileDownloads]]; - [newRequest setUserInfo:[[[self userInfo] copyWithZone:zone] autorelease]]; + [newRequest setUserInfo:[[self userInfo] copyWithZone:zone]]; [newRequest setTag:[self tag]]; [newRequest setUseHTTPVersionOne:[self useHTTPVersionOne]]; [newRequest setShouldRedirect:[self shouldRedirect]]; [newRequest setValidatesSecureCertificate:[self validatesSecureCertificate]]; [newRequest setClientCertificateIdentity:clientCertificateIdentity]; - [newRequest setClientCertificates:[[clientCertificates copy] autorelease]]; + [newRequest setClientCertificates:[_clientCertificates copy]]; [newRequest setPACurl:[self PACurl]]; [newRequest setShouldPresentCredentialsBeforeChallenge:[self shouldPresentCredentialsBeforeChallenge]]; [newRequest setNumberOfTimesToRetryOnTimeout:[self numberOfTimesToRetryOnTimeout]]; @@ -4282,31 +4292,31 @@ - (NSDictionary *)findSessionAuthenticationCredentials + (void)saveCredentials:(NSURLCredential *)credentials forHost:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm { - NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:NSURLAuthenticationMethodDefault] autorelease]; + NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:NSURLAuthenticationMethodDefault]; [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credentials forProtectionSpace:protectionSpace]; } + (void)saveCredentials:(NSURLCredential *)credentials forProxy:(NSString *)host port:(int)port realm:(NSString *)realm { - NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithProxyHost:host port:port type:NSURLProtectionSpaceHTTPProxy realm:realm authenticationMethod:NSURLAuthenticationMethodDefault] autorelease]; + NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithProxyHost:host port:port type:NSURLProtectionSpaceHTTPProxy realm:realm authenticationMethod:NSURLAuthenticationMethodDefault]; [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credentials forProtectionSpace:protectionSpace]; } + (NSURLCredential *)savedCredentialsForHost:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm { - NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:NSURLAuthenticationMethodDefault] autorelease]; + NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:NSURLAuthenticationMethodDefault]; return [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace]; } + (NSURLCredential *)savedCredentialsForProxy:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm { - NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithProxyHost:host port:port type:NSURLProtectionSpaceHTTPProxy realm:realm authenticationMethod:NSURLAuthenticationMethodDefault] autorelease]; + NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithProxyHost:host port:port type:NSURLProtectionSpaceHTTPProxy realm:realm authenticationMethod:NSURLAuthenticationMethodDefault]; return [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace]; } + (void)removeCredentialsForHost:(NSString *)host port:(int)port protocol:(NSString *)protocol realm:(NSString *)realm { - NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:NSURLAuthenticationMethodDefault] autorelease]; + NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:host port:port protocol:protocol realm:realm authenticationMethod:NSURLAuthenticationMethodDefault]; NSURLCredential *credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace]; if (credential) { [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:credential forProtectionSpace:protectionSpace]; @@ -4315,7 +4325,7 @@ + (void)removeCredentialsForHost:(NSString *)host port:(int)port protocol:(NSStr + (void)removeCredentialsForProxy:(NSString *)host port:(int)port realm:(NSString *)realm { - NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc] initWithProxyHost:host port:port type:NSURLProtectionSpaceHTTPProxy realm:realm authenticationMethod:NSURLAuthenticationMethodDefault] autorelease]; + NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithProxyHost:host port:port type:NSURLProtectionSpaceHTTPProxy realm:realm authenticationMethod:NSURLAuthenticationMethodDefault]; NSURLCredential *credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace]; if (credential) { [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:credential forProtectionSpace:protectionSpace]; @@ -4328,9 +4338,8 @@ + (NSMutableArray *)sessionCookies if (!sessionCookies) { [ASIHTTPRequest setSessionCookies:[NSMutableArray array]]; } - NSMutableArray *cookies = [[sessionCookies retain] autorelease]; [sessionCookiesLock unlock]; - return cookies; + return sessionCookies; } + (void)setSessionCookies:(NSMutableArray *)newSessionCookies @@ -4340,8 +4349,7 @@ + (void)setSessionCookies:(NSMutableArray *)newSessionCookies for (NSHTTPCookie *cookie in sessionCookies) { [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; } - [sessionCookies release]; - sessionCookies = [newSessionCookies retain]; + sessionCookies = newSessionCookies; [sessionCookiesLock unlock]; } @@ -4389,7 +4397,7 @@ + (NSString *)defaultUserAgentString } NSData *latin1Data = [appName dataUsingEncoding:NSUTF8StringEncoding]; - appName = [[[NSString alloc] initWithData:latin1Data encoding:NSISOLatin1StringEncoding] autorelease]; + appName = [[NSString alloc] initWithData:latin1Data encoding:NSISOLatin1StringEncoding]; // If we couldn't find one, we'll give up (and ASIHTTPRequest will use the standard CFNetwork user agent) if (!appName) { @@ -4440,7 +4448,7 @@ + (NSString *)defaultUserAgentString // Takes the form "My Application 1.0 (Macintosh; Mac OS X 10.5.7; en_GB)" [self setDefaultUserAgentString:[NSString stringWithFormat:@"%@ %@ (%@; %@ %@; %@)", appName, appVersion, deviceName, OSName, OSVersion, locale]]; } - return [[defaultUserAgent retain] autorelease]; + return defaultUserAgent; } return nil; } @@ -4451,7 +4459,6 @@ + (void)setDefaultUserAgentString:(NSString *)agent if (defaultUserAgent == agent) { return; } - [defaultUserAgent release]; defaultUserAgent = [agent copy]; } } @@ -4461,17 +4468,17 @@ + (void)setDefaultUserAgentString:(NSString *)agent + (NSString *)mimeTypeForFileAtPath:(NSString *)path { - if (![[[[NSFileManager alloc] init] autorelease] fileExistsAtPath:path]) { + if (![[[NSFileManager alloc] init] fileExistsAtPath:path]) { return nil; } // Borrowed from http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database - CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[path pathExtension], NULL); + CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[path pathExtension], NULL); CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType); CFRelease(UTI); if (!MIMEType) { return @"application/octet-stream"; } - return [NSMakeCollectable(MIMEType) autorelease]; + return (__bridge_transfer NSString *)(MIMEType); } #pragma mark bandwidth measurement / throttling @@ -4563,8 +4570,7 @@ + (void)recordBandwidthUsage ASI_DEBUG_LOG(@"[THROTTLING] ===Used: %u bytes of bandwidth in last measurement period===",bandwidthUsedInLastSecond); #endif [bandwidthUsageTracker addObject:[NSNumber numberWithUnsignedLong:bandwidthUsedInLastSecond]]; - [bandwidthMeasurementDate release]; - bandwidthMeasurementDate = [[NSDate dateWithTimeIntervalSinceNow:1] retain]; + bandwidthMeasurementDate = [NSDate dateWithTimeIntervalSinceNow:1]; bandwidthUsedInLastSecond = 0; NSUInteger measurements = [bandwidthUsageTracker count]; @@ -4609,7 +4615,6 @@ + (void)measureBandwidthUsage // Yes, put this request to sleep until a second is up, with extra added punishment sleeping time for being very naughty (we have used more bandwidth than we were allowed) double extraSleepyTime = (-bytesRemaining/(maxBandwidthPerSecond*1.0)); - [throttleWakeUpTime release]; throttleWakeUpTime = [[NSDate alloc] initWithTimeInterval:extraSleepyTime sinceDate:bandwidthMeasurementDate]; } } @@ -4622,7 +4627,7 @@ + (unsigned long)maxUploadReadLength // We'll split our bandwidth allowance into 4 (which is the default for an ASINetworkQueue's max concurrent operations count) to give all running requests a fighting chance of reading data this cycle long long toRead = maxBandwidthPerSecond/4; - if (maxBandwidthPerSecond > 0 && (bandwidthUsedInLastSecond + toRead > maxBandwidthPerSecond)) { + if (maxBandwidthPerSecond > 0 && ((long long)bandwidthUsedInLastSecond + toRead > (long long)maxBandwidthPerSecond)) { toRead = (long long)maxBandwidthPerSecond-(long long)bandwidthUsedInLastSecond; if (toRead < 0) { toRead = 0; @@ -4630,8 +4635,7 @@ + (unsigned long)maxUploadReadLength } if (toRead == 0 || !bandwidthMeasurementDate || [bandwidthMeasurementDate timeIntervalSinceNow] < -0) { - [throttleWakeUpTime release]; - throttleWakeUpTime = [bandwidthMeasurementDate retain]; + throttleWakeUpTime = bandwidthMeasurementDate; } [bandwidthThrottlingLock unlock]; return (unsigned long)toRead; @@ -4695,7 +4699,7 @@ + (void)reachabilityChanged:(NSNotification *)note // Returns the shared queue + (NSOperationQueue *)sharedQueue { - return [[sharedQueue retain] autorelease]; + return sharedQueue; } #pragma mark cache @@ -4703,8 +4707,6 @@ + (NSOperationQueue *)sharedQueue + (void)setDefaultCache:(id )cache { @synchronized (self) { - [cache retain]; - [defaultCache release]; defaultCache = cache; } } @@ -4712,7 +4714,7 @@ + (void)setDefaultCache:(id )cache + (id )defaultCache { @synchronized(self) { - return [[defaultCache retain] autorelease]; + return defaultCache; } return nil; } @@ -4737,15 +4739,24 @@ + (void)setShouldUpdateNetworkActivityIndicator:(BOOL)shouldUpdate + (void)showNetworkActivityIndicator { +#ifndef TARGET_IS_EXTENSION #if TARGET_OS_IPHONE - [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; + + }); +#endif #endif } + (void)hideNetworkActivityIndicator { +#ifndef TARGET_IS_EXTENSION #if TARGET_OS_IPHONE - [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; + }); +#endif #endif } @@ -4797,9 +4808,9 @@ + (void)runRequests BOOL runAlways = YES; // Introduced to cheat Static Analyzer while (runAlways) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e10, true); - [pool drain]; + } } // Should never be called, but anyway @@ -4849,7 +4860,7 @@ + (NSString*)base64forData:(NSData*)theData { output[theIndex + 3] = (i + 2) < length ? (uint8_t)table[(value >> 0) & 0x3F] : '='; } - return [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease]; + return [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; } + (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge @@ -4873,7 +4884,7 @@ + (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterva if (maxAge) { NSDate *date = [NSDate date]; if ([date respondsToSelector:@selector(dateByAddingTimeInterval:)]) { - return [date dateByAddingTimeInterval:maxAge]; + return [[NSDate date] dateByAddingTimeInterval:maxAge]; } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -4892,8 +4903,8 @@ + (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterva // Based on hints from http://stackoverflow.com/questions/1850824/parsing-a-rfc-822-date-with-nsdateformatter + (NSDate *)dateFromRFC1123String:(NSString *)string { - NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; - [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]]; + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; // Does the string include a week day? NSString *day = @""; if ([string rangeOfString:@","].location != NSNotFound) { @@ -4928,7 +4939,7 @@ + (void)parseMimeType:(NSString **)mimeType andResponseEncoding:(NSStringEncodin } if (IANAEncoding) { - CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)IANAEncoding); + CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)IANAEncoding); if (cfEncoding != kCFStringEncodingInvalidId) { *stringEncoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding); } @@ -4940,196 +4951,100 @@ + (void)parseMimeType:(NSString **)mimeType andResponseEncoding:(NSStringEncodin #if NS_BLOCKS_AVAILABLE - (void)setStartedBlock:(ASIBasicBlock)aStartedBlock { - [startedBlock release]; startedBlock = [aStartedBlock copy]; } - (void)setHeadersReceivedBlock:(ASIHeadersBlock)aReceivedBlock { - [headersReceivedBlock release]; headersReceivedBlock = [aReceivedBlock copy]; } - (void)setCompletionBlock:(ASIBasicBlock)aCompletionBlock { - [completionBlock release]; completionBlock = [aCompletionBlock copy]; } - (void)setFailedBlock:(ASIBasicBlock)aFailedBlock { - [failureBlock release]; failureBlock = [aFailedBlock copy]; } - (void)setBytesReceivedBlock:(ASIProgressBlock)aBytesReceivedBlock { - [bytesReceivedBlock release]; bytesReceivedBlock = [aBytesReceivedBlock copy]; } - (void)setBytesSentBlock:(ASIProgressBlock)aBytesSentBlock { - [bytesSentBlock release]; bytesSentBlock = [aBytesSentBlock copy]; } - (void)setDownloadSizeIncrementedBlock:(ASISizeBlock)aDownloadSizeIncrementedBlock{ - [downloadSizeIncrementedBlock release]; downloadSizeIncrementedBlock = [aDownloadSizeIncrementedBlock copy]; } - (void)setUploadSizeIncrementedBlock:(ASISizeBlock)anUploadSizeIncrementedBlock { - [uploadSizeIncrementedBlock release]; uploadSizeIncrementedBlock = [anUploadSizeIncrementedBlock copy]; } - (void)setDataReceivedBlock:(ASIDataBlock)aReceivedBlock { - [dataReceivedBlock release]; dataReceivedBlock = [aReceivedBlock copy]; } - (void)setAuthenticationNeededBlock:(ASIBasicBlock)anAuthenticationBlock { - [authenticationNeededBlock release]; authenticationNeededBlock = [anAuthenticationBlock copy]; } - (void)setProxyAuthenticationNeededBlock:(ASIBasicBlock)aProxyAuthenticationBlock { - [proxyAuthenticationNeededBlock release]; proxyAuthenticationNeededBlock = [aProxyAuthenticationBlock copy]; } - (void)setRequestRedirectedBlock:(ASIBasicBlock)aRedirectBlock { - [requestRedirectedBlock release]; requestRedirectedBlock = [aRedirectBlock copy]; } #endif #pragma mark === -@synthesize username; -@synthesize password; -@synthesize userAgentString; -@synthesize domain; -@synthesize proxyUsername; -@synthesize proxyPassword; -@synthesize proxyDomain; -@synthesize url; -@synthesize originalURL; -@synthesize delegate; -@synthesize queue; -@synthesize uploadProgressDelegate; -@synthesize downloadProgressDelegate; @synthesize useKeychainPersistence; -@synthesize useSessionPersistence; -@synthesize useCookiePersistence; -@synthesize downloadDestinationPath; -@synthesize temporaryFileDownloadPath; -@synthesize temporaryUncompressedDataDownloadPath; -@synthesize didStartSelector; -@synthesize didReceiveResponseHeadersSelector; -@synthesize willRedirectSelector; -@synthesize didFinishSelector; -@synthesize didFailSelector; -@synthesize didReceiveDataSelector; -@synthesize authenticationRealm; -@synthesize proxyAuthenticationRealm; -@synthesize error; -@synthesize complete; -@synthesize requestHeaders; -@synthesize responseHeaders; -@synthesize responseCookies; -@synthesize requestCookies; -@synthesize requestCredentials; @synthesize responseStatusCode; -@synthesize rawResponseData; -@synthesize lastActivityTime; -@synthesize timeOutSeconds; -@synthesize requestMethod; -@synthesize postBody; @synthesize compressedPostBody; -@synthesize contentLength; @synthesize partialDownloadSize; @synthesize postLength; -@synthesize shouldResetDownloadProgress; -@synthesize shouldResetUploadProgress; -@synthesize mainRequest; -@synthesize totalBytesRead; -@synthesize totalBytesSent; -@synthesize showAccurateProgress; @synthesize uploadBufferSize; -@synthesize defaultResponseEncoding; @synthesize responseEncoding; -@synthesize allowCompressedResponse; @synthesize allowResumeForFileDownloads; -@synthesize userInfo; @synthesize tag; -@synthesize postBodyFilePath; -@synthesize compressedPostBodyFilePath; -@synthesize postBodyWriteStream; -@synthesize postBodyReadStream; -@synthesize shouldStreamPostDataFromDisk; -@synthesize didCreateTemporaryPostDataFile; @synthesize useHTTPVersionOne; @synthesize lastBytesRead; @synthesize lastBytesSent; -@synthesize cancelledLock; -@synthesize haveBuiltPostBody; @synthesize fileDownloadOutputStream; -@synthesize inflatedFileDownloadOutputStream; @synthesize authenticationRetryCount; @synthesize proxyAuthenticationRetryCount; @synthesize updatedProgress; -@synthesize shouldRedirect; -@synthesize validatesSecureCertificate; -@synthesize needsRedirect; @synthesize redirectCount; -@synthesize shouldCompressRequestBody; -@synthesize proxyCredentials; -@synthesize proxyHost; @synthesize proxyPort; -@synthesize proxyType; -@synthesize PACurl; -@synthesize authenticationScheme; -@synthesize proxyAuthenticationScheme; @synthesize shouldPresentAuthenticationDialog; -@synthesize shouldPresentProxyAuthenticationDialog; @synthesize authenticationNeeded; -@synthesize responseStatusMessage; -@synthesize shouldPresentCredentialsBeforeChallenge; @synthesize haveBuiltRequestHeaders; @synthesize inProgress; @synthesize numberOfTimesToRetryOnTimeout; @synthesize retryCount; @synthesize willRetryRequest; -@synthesize shouldAttemptPersistentConnection; -@synthesize persistentConnectionTimeoutSeconds; @synthesize connectionCanBeReused; -@synthesize connectionInfo; -@synthesize readStream; -@synthesize readStreamIsScheduled; @synthesize shouldUseRFC2616RedirectBehaviour; @synthesize downloadComplete; -@synthesize requestID; -@synthesize runLoopMode; -@synthesize statusTimer; -@synthesize downloadCache; @synthesize cachePolicy; @synthesize cacheStoragePolicy; @synthesize didUseCachedResponse; @synthesize secondsToCache; -@synthesize clientCertificates; -@synthesize redirectURL; #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 @synthesize shouldContinueWhenAppEntersBackground; #endif -@synthesize dataDecompressor; -@synthesize shouldWaitToInflateCompressedResponses; -@synthesize isPACFileRequest; @synthesize PACFileRequest; @synthesize PACFileReadStream; @synthesize PACFileData; diff --git a/Classes/ASIInputStream.h b/Classes/ASIInputStream.h index 7b9f93ed..150853ec 100644 --- a/Classes/ASIInputStream.h +++ b/Classes/ASIInputStream.h @@ -14,13 +14,11 @@ // Subclassing NSInputStream seems to be tricky, and may involve overriding undocumented methods, so we'll cheat instead. // It is used by ASIHTTPRequest whenever we have a request body, and handles measuring and throttling the bandwidth used for uploading -@interface ASIInputStream : NSObject { - NSInputStream *stream; - ASIHTTPRequest *request; -} -+ (id)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)request; -+ (id)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)request; +@interface ASIInputStream : NSInputStream -@property (retain, nonatomic) NSInputStream *stream; -@property (assign, nonatomic) ASIHTTPRequest *request; ++ (instancetype)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)request; ++ (instancetype)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)request; +- (id)initWithInputStream:(NSInputStream *)stream; + +@property (weak, nonatomic) ASIHTTPRequest *request; @end diff --git a/Classes/ASIInputStream.m b/Classes/ASIInputStream.m index dc998eb9..91bbbad6 100644 --- a/Classes/ASIInputStream.m +++ b/Classes/ASIInputStream.m @@ -8,11 +8,20 @@ #import "ASIInputStream.h" #import "ASIHTTPRequest.h" +#import // Used to ensure only one request can read data at once static NSLock *readLock = nil; @implementation ASIInputStream +{ + NSInputStream *_stream; + id delegate; + + CFReadStreamClientCallBack copiedCallback; + CFStreamClientContext copiedContext; + CFOptionFlags requestedEvents; +} + (void)initialize { @@ -21,50 +30,38 @@ + (void)initialize } } -+ (id)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)theRequest ++ (instancetype)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)theRequest { - ASIInputStream *theStream = [[[self alloc] init] autorelease]; + ASIInputStream *theStream = [[ASIInputStream alloc] initWithInputStream:[NSInputStream inputStreamWithFileAtPath:path]]; [theStream setRequest:theRequest]; - [theStream setStream:[NSInputStream inputStreamWithFileAtPath:path]]; return theStream; } -+ (id)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)theRequest ++ (instancetype)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)theRequest { - ASIInputStream *theStream = [[[self alloc] init] autorelease]; + ASIInputStream *theStream = [[ASIInputStream alloc] initWithInputStream:[NSInputStream inputStreamWithData:data]]; [theStream setRequest:theRequest]; - [theStream setStream:[NSInputStream inputStreamWithData:data]]; return theStream; } -- (void)dealloc -{ - [stream release]; - [super dealloc]; -} +#pragma mark - Object lifecycle -// Called when CFNetwork wants to read more of our request body -// When throttling is on, we ask ASIHTTPRequest for the maximum amount of data we can read -- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len +- (id)initWithInputStream:(NSInputStream *)aStream { - [readLock lock]; - unsigned long toRead = len; - if ([ASIHTTPRequest isBandwidthThrottled]) { - toRead = [ASIHTTPRequest maxUploadReadLength]; - if (toRead > len) { - toRead = len; - } else if (toRead == 0) { - toRead = 1; - } - [request performThrottling]; - } - [readLock unlock]; - NSInteger rv = [stream read:buffer maxLength:toRead]; - if (rv > 0) - [ASIHTTPRequest incrementBandwidthUsedInLastSecond:(NSUInteger)rv]; - return rv; + self = [super init]; + if (self) { + // Initialization code here. + _stream = aStream; + [_stream setDelegate:self]; + + [self setDelegate:self]; + } + + return self; } +#pragma mark - NSStream subclass methods + /* * Implement NSInputStream mandatory methods to make sure they are implemented * (necessary for MacRuby for example) and avoid the overhead of method @@ -72,52 +69,200 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len */ - (void)open { - [stream open]; + [_stream open]; } - (void)close { - [stream close]; + [_stream close]; } -- (id)delegate +- (id )delegate { - return [stream delegate]; + return delegate; } -- (void)setDelegate:(id)delegate +- (void)setDelegate:(id)aDelegate { - [stream setDelegate:delegate]; + if (aDelegate == nil) { + delegate = self; + } + else { + delegate = aDelegate; + } } - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode { - [stream scheduleInRunLoop:aRunLoop forMode:mode]; + [_stream scheduleInRunLoop:aRunLoop forMode:mode]; } - (void)removeFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode { - [stream removeFromRunLoop:aRunLoop forMode:mode]; + [_stream removeFromRunLoop:aRunLoop forMode:mode]; } - (id)propertyForKey:(NSString *)key { - return [stream propertyForKey:key]; + return [_stream propertyForKey:key]; } - (BOOL)setProperty:(id)property forKey:(NSString *)key { - return [stream setProperty:property forKey:key]; + return [_stream setProperty:property forKey:key]; } - (NSStreamStatus)streamStatus { - return [stream streamStatus]; + return [_stream streamStatus]; } - (NSError *)streamError { - return [stream streamError]; + return [_stream streamError]; +} + +#pragma mark - NSInputStream subclass methods + +// Called when CFNetwork wants to read more of our request body +// When throttling is on, we ask ASIHTTPRequest for the maximum amount of data we can read +- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len +{ + [readLock lock]; + unsigned long toRead = len; + if ([ASIHTTPRequest isBandwidthThrottled]) { + toRead = [ASIHTTPRequest maxUploadReadLength]; + if (toRead > len) { + toRead = len; + } else if (toRead == 0) { + toRead = 1; + } + [_request performThrottling]; + } + [readLock unlock]; + NSInteger rv = [_stream read:buffer maxLength:toRead]; + if (rv > 0) + [ASIHTTPRequest incrementBandwidthUsedInLastSecond:(NSUInteger)rv]; + return rv; +} + + +- (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len +{ + // We cannot implement our character-counting in O(1) time, + // so we return NO as indicated in the NSInputStream + // documentation. + return NO; +} + +- (BOOL)hasBytesAvailable +{ + return [_stream hasBytesAvailable]; +} + +#pragma mark - Undocumented CFReadStream bridged methods + ++ (BOOL)resolveInstanceMethod:(SEL) selector +{ + NSString *name = NSStringFromSelector(selector); + + if ([name hasPrefix:@"_"]){ + name = [name substringFromIndex:1]; + SEL aSelector = NSSelectorFromString(name); + Method method = class_getInstanceMethod(self, aSelector); + + if (method) + { + class_addMethod(self, + selector, + method_getImplementation(method), + method_getTypeEncoding(method)); + return YES; + } + } + return [super resolveInstanceMethod:selector]; +} + +- (void)scheduleInCFRunLoop:(CFRunLoopRef)aRunLoop forMode:(CFStringRef)aMode +{ + CFReadStreamScheduleWithRunLoop((CFReadStreamRef)_stream, aRunLoop, aMode); +} + +- (BOOL)setCFClientFlags:(CFOptionFlags)inFlags callback:(CFReadStreamClientCallBack)inCallback context:(CFStreamClientContext *)inContext +{ + if (inCallback != NULL) { + requestedEvents = inFlags; + copiedCallback = inCallback; + memcpy(&copiedContext, inContext, sizeof(CFStreamClientContext)); + + if (copiedContext.info && copiedContext.retain) { + copiedContext.retain(copiedContext.info); + } + } + else { + requestedEvents = kCFStreamEventNone; + copiedCallback = NULL; + if (copiedContext.info && copiedContext.release) { + copiedContext.release(copiedContext.info); + } + + memset(&copiedContext, 0, sizeof(CFStreamClientContext)); + } + + return YES; +} + +- (void)unscheduleFromCFRunLoop:(CFRunLoopRef)aRunLoop forMode:(CFStringRef)aMode +{ + CFReadStreamUnscheduleFromRunLoop((CFReadStreamRef)_stream, aRunLoop, aMode); +} + +#pragma mark - NSStreamDelegate methods + +- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode +{ + assert(aStream ==_stream); + + switch (eventCode) { + case NSStreamEventOpenCompleted: + if (requestedEvents & kCFStreamEventOpenCompleted) { + copiedCallback((__bridge CFReadStreamRef)self, + kCFStreamEventOpenCompleted, + copiedContext.info); + } + break; + + case NSStreamEventHasBytesAvailable: + if (requestedEvents & kCFStreamEventHasBytesAvailable) { + copiedCallback((__bridge CFReadStreamRef)self, + kCFStreamEventHasBytesAvailable, + copiedContext.info); + } + break; + + case NSStreamEventErrorOccurred: + if (requestedEvents & kCFStreamEventErrorOccurred) { + copiedCallback((__bridge CFReadStreamRef)self, + kCFStreamEventErrorOccurred, + copiedContext.info); + } + break; + + case NSStreamEventEndEncountered: + if (requestedEvents & kCFStreamEventEndEncountered) { + copiedCallback((__bridge CFReadStreamRef)self, + kCFStreamEventEndEncountered, + copiedContext.info); + } + break; + + case NSStreamEventHasSpaceAvailable: + // This doesn't make sense for a read stream + break; + + default: + break; + } } // If we get asked to perform a method we don't have (probably internal ones), @@ -125,14 +270,12 @@ - (NSError *)streamError - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { - return [stream methodSignatureForSelector:aSelector]; + return [_stream methodSignatureForSelector:aSelector]; } - (void)forwardInvocation:(NSInvocation *)anInvocation { - [anInvocation invokeWithTarget:stream]; + [anInvocation invokeWithTarget:_stream]; } -@synthesize stream; -@synthesize request; @end diff --git a/Classes/ASINetworkQueue.h b/Classes/ASINetworkQueue.h index 6829b56a..c15fde5e 100644 --- a/Classes/ASINetworkQueue.h +++ b/Classes/ASINetworkQueue.h @@ -12,63 +12,8 @@ @interface ASINetworkQueue : NSOperationQueue { - // Delegate will get didFail + didFinish messages (if set) - id delegate; - - // Will be called when a request starts with the request as the argument - SEL requestDidStartSelector; - - // Will be called when a request receives response headers - // Should take the form request:didRecieveResponseHeaders:, where the first argument is the request, and the second the headers dictionary - SEL requestDidReceiveResponseHeadersSelector; - - // Will be called when a request is about to redirect - // Should take the form request:willRedirectToURL:, where the first argument is the request, and the second the new url - SEL requestWillRedirectSelector; - - // Will be called when a request completes with the request as the argument - SEL requestDidFinishSelector; - - // Will be called when a request fails with the request as the argument - SEL requestDidFailSelector; - - // Will be called when the queue finishes with the queue as the argument - SEL queueDidFinishSelector; - - // Upload progress indicator, probably an NSProgressIndicator or UIProgressView - id uploadProgressDelegate; - - // Total amount uploaded so far for all requests in this queue - unsigned long long bytesUploadedSoFar; - - // Total amount to be uploaded for all requests in this queue - requests add to this figure as they work out how much data they have to transmit - unsigned long long totalBytesToUpload; - - // Download progress indicator, probably an NSProgressIndicator or UIProgressView - id downloadProgressDelegate; - - // Total amount downloaded so far for all requests in this queue - unsigned long long bytesDownloadedSoFar; - - // Total amount to be downloaded for all requests in this queue - requests add to this figure as they receive Content-Length headers - unsigned long long totalBytesToDownload; - - // When YES, the queue will cancel all requests when a request fails. Default is YES - BOOL shouldCancelAllRequestsOnFailure; - //Number of real requests (excludes HEAD requests created to manage showAccurateProgress) - int requestsCount; - - // When NO, this request will only update the progress indicator when it completes - // When YES, this request will update the progress indicator according to how much data it has received so far - // When YES, the queue will first perform HEAD requests for all GET requests in the queue, so it can calculate the total download size before it starts - // NO means better performance, because it skips this step for GET requests, and it won't waste time updating the progress indicator until a request completes - // Set to YES if the size of a requests in the queue varies greatly for much more accurate results - // Default for requests in the queue is NO - BOOL showAccurateProgress; - - // Storage container for additional queue information. - NSDictionary *userInfo; + int _requestsCount; } @@ -85,24 +30,62 @@ // This method will start the queue - (void)go; -@property (assign, nonatomic, setter=setUploadProgressDelegate:) id uploadProgressDelegate; -@property (assign, nonatomic, setter=setDownloadProgressDelegate:) id downloadProgressDelegate; +// Upload progress indicator, probably an NSProgressIndicator or UIProgressView +@property (weak, nonatomic, setter=setUploadProgressDelegate:) id uploadProgressDelegate; +// Download progress indicator, probably an NSProgressIndicator or UIProgressView +@property (weak, nonatomic, setter=setDownloadProgressDelegate:) id downloadProgressDelegate; + +// Will be called when a request starts with the request as the argument @property (assign, atomic) SEL requestDidStartSelector; + +// Will be called when a request receives response headers +// Should take the form request:didRecieveResponseHeaders:, where the first argument is the request, and the second the headers dictionary @property (assign, atomic) SEL requestDidReceiveResponseHeadersSelector; + +// Will be called when a request is about to redirect +// Should take the form request:willRedirectToURL:, where the first argument is the request, and the second the new url @property (assign, atomic) SEL requestWillRedirectSelector; + +// Will be called when a request completes with the request as the argument @property (assign, atomic) SEL requestDidFinishSelector; + +// Will be called when a request fails with the request as the argument @property (assign, atomic) SEL requestDidFailSelector; + +// Will be called when the queue finishes with the queue as the argument @property (assign, atomic) SEL queueDidFinishSelector; + +// When YES, the queue will cancel all requests when a request fails. Default is YES @property (assign, atomic) BOOL shouldCancelAllRequestsOnFailure; -@property (assign, atomic) id delegate; + +// Delegate will get didFail + didFinish messages (if set) +@property (weak, atomic) id delegate; + +// When NO, this request will only update the progress indicator when it completes +// When YES, this request will update the progress indicator according to how much data it has received so far +// When YES, the queue will first perform HEAD requests for all GET requests in the queue, so it can calculate the total download size before it starts +// NO means better performance, because it skips this step for GET requests, and it won't waste time updating the progress indicator until a request completes +// Set to YES if the size of a requests in the queue varies greatly for much more accurate results +// Default for requests in the queue is NO @property (assign, atomic) BOOL showAccurateProgress; + +//Number of real requests (excludes HEAD requests created to manage showAccurateProgress) @property (assign, atomic, readonly) int requestsCount; + +// Storage container for additional queue information. @property (retain, atomic) NSDictionary *userInfo; +// Total amount uploaded so far for all requests in this queue @property (assign, atomic) unsigned long long bytesUploadedSoFar; + +// Total amount to be uploaded for all requests in this queue - requests add to this figure as they work out how much data they have to transmit @property (assign, atomic) unsigned long long totalBytesToUpload; + +// Total amount downloaded so far for all requests in this queue @property (assign, atomic) unsigned long long bytesDownloadedSoFar; + +// Total amount to be downloaded for all requests in this queue - requests add to this figure as they receive Content-Length headers @property (assign, atomic) unsigned long long totalBytesToDownload; @end diff --git a/Classes/ASINetworkQueue.m b/Classes/ASINetworkQueue.m index fd8a9496..70073a9e 100644 --- a/Classes/ASINetworkQueue.m +++ b/Classes/ASINetworkQueue.m @@ -9,10 +9,20 @@ #import "ASINetworkQueue.h" #import "ASIHTTPRequest.h" +#define ASISuppressPerformSelectorLeakWarning(Stuff) \ +do { \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ +Stuff \ +_Pragma("clang diagnostic pop") \ +} while (0) + // Private stuff @interface ASINetworkQueue () - - (void)resetProgressDelegate:(id *)progressDelegate; - @property (assign) int requestsCount; + +- (void)resetProgressDelegate:(id)progressDelegate; +@property (assign, atomic) int requestsCount; + @end @implementation ASINetworkQueue @@ -29,7 +39,7 @@ - (id)init + (id)queue { - return [[[self alloc] init] autorelease]; + return [[self alloc] init]; } - (void)dealloc @@ -38,8 +48,6 @@ - (void)dealloc for (ASIHTTPRequest *request in [self operations]) { [request setQueue:nil]; } - [userInfo release]; - [super dealloc]; } - (void)setSuspended:(BOOL)suspend @@ -78,34 +86,34 @@ - (void)cancelAllOperations - (void)setUploadProgressDelegate:(id)newDelegate { - uploadProgressDelegate = newDelegate; - [self resetProgressDelegate:&uploadProgressDelegate]; + _uploadProgressDelegate = newDelegate; + [self resetProgressDelegate:_uploadProgressDelegate]; } - (void)setDownloadProgressDelegate:(id)newDelegate { - downloadProgressDelegate = newDelegate; - [self resetProgressDelegate:&downloadProgressDelegate]; + _downloadProgressDelegate = newDelegate; + [self resetProgressDelegate:_downloadProgressDelegate]; } -- (void)resetProgressDelegate:(id *)progressDelegate +- (void)resetProgressDelegate:(id)progressDelegate { #if !TARGET_OS_IPHONE // If the uploadProgressDelegate is an NSProgressIndicator, we set its MaxValue to 1.0 so we can treat it similarly to UIProgressViews SEL selector = @selector(setMaxValue:); - if ([*progressDelegate respondsToSelector:selector]) { + if ([progressDelegate respondsToSelector:selector]) { double max = 1.0; [ASIHTTPRequest performSelector:selector onTarget:progressDelegate withObject:nil amount:&max callerToRetain:nil]; } selector = @selector(setDoubleValue:); - if ([*progressDelegate respondsToSelector:selector]) { + if ([progressDelegate respondsToSelector:selector]) { double value = 0.0; [ASIHTTPRequest performSelector:selector onTarget:progressDelegate withObject:nil amount:&value callerToRetain:nil]; } #else SEL selector = @selector(setProgress:); - if ([*progressDelegate respondsToSelector:selector]) { + if ([progressDelegate respondsToSelector:selector]) { float value = 0.0f; [ASIHTTPRequest performSelector:selector onTarget:progressDelegate withObject:nil amount:&value callerToRetain:nil]; } @@ -153,7 +161,7 @@ - (void)addOperation:(NSOperation *)operation [self addHEADOperation:HEADRequest]; [request addDependency:HEADRequest]; if ([request shouldResetDownloadProgress]) { - [self resetProgressDelegate:&downloadProgressDelegate]; + [self resetProgressDelegate:_downloadProgressDelegate]; [request setShouldResetDownloadProgress:NO]; } } @@ -168,7 +176,7 @@ - (void)addOperation:(NSOperation *)operation } // Tell the request not to increment the upload size when it starts, as we've already added its length if ([request shouldResetUploadProgress]) { - [self resetProgressDelegate:&uploadProgressDelegate]; + [self resetProgressDelegate:_uploadProgressDelegate]; [request setShouldResetUploadProgress:NO]; } @@ -182,21 +190,27 @@ - (void)addOperation:(NSOperation *)operation - (void)requestStarted:(ASIHTTPRequest *)request { if ([self requestDidStartSelector]) { - [[self delegate] performSelector:[self requestDidStartSelector] withObject:request]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self requestDidStartSelector] withObject:request]; + ); } } - (void)request:(ASIHTTPRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders { if ([self requestDidReceiveResponseHeadersSelector]) { - [[self delegate] performSelector:[self requestDidReceiveResponseHeadersSelector] withObject:request withObject:responseHeaders]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self requestDidReceiveResponseHeadersSelector] withObject:request withObject:responseHeaders]; + ); } } - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL { if ([self requestWillRedirectSelector]) { - [[self delegate] performSelector:[self requestWillRedirectSelector] withObject:request withObject:newURL]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self requestWillRedirectSelector] withObject:request withObject:newURL]; + ); } } @@ -204,11 +218,15 @@ - (void)requestFinished:(ASIHTTPRequest *)request { [self setRequestsCount:[self requestsCount]-1]; if ([self requestDidFinishSelector]) { - [[self delegate] performSelector:[self requestDidFinishSelector] withObject:request]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self requestDidFinishSelector] withObject:request]; + ); } if ([self requestsCount] == 0) { if ([self queueDidFinishSelector]) { - [[self delegate] performSelector:[self queueDidFinishSelector] withObject:self]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self queueDidFinishSelector] withObject:self]; + ); } } } @@ -217,11 +235,15 @@ - (void)requestFailed:(ASIHTTPRequest *)request { [self setRequestsCount:[self requestsCount]-1]; if ([self requestDidFailSelector]) { - [[self delegate] performSelector:[self requestDidFailSelector] withObject:request]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self requestDidFailSelector] withObject:request]; + ); } if ([self requestsCount] == 0) { if ([self queueDidFinishSelector]) { - [[self delegate] performSelector:[self queueDidFinishSelector] withObject:self]; + ASISuppressPerformSelectorLeakWarning( + [[self delegate] performSelector:[self queueDidFinishSelector] withObject:self]; + ); } } if ([self shouldCancelAllRequestsOnFailure] && [self requestsCount] > 0) { @@ -235,7 +257,7 @@ - (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes { [self setBytesDownloadedSoFar:[self bytesDownloadedSoFar]+(unsigned long long)bytes]; if ([self downloadProgressDelegate]) { - [ASIHTTPRequest updateProgressIndicator:&downloadProgressDelegate withProgress:[self bytesDownloadedSoFar] ofTotal:[self totalBytesToDownload]]; + [ASIHTTPRequest updateProgressIndicator:_downloadProgressDelegate withProgress:[self bytesDownloadedSoFar] ofTotal:[self totalBytesToDownload]]; } } @@ -243,7 +265,7 @@ - (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes { [self setBytesUploadedSoFar:[self bytesUploadedSoFar]+(unsigned long long)bytes]; if ([self uploadProgressDelegate]) { - [ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:[self bytesUploadedSoFar] ofTotal:[self totalBytesToUpload]]; + [ASIHTTPRequest updateProgressIndicator:_uploadProgressDelegate withProgress:[self bytesUploadedSoFar] ofTotal:[self totalBytesToUpload]]; } } @@ -318,26 +340,8 @@ - (id)copyWithZone:(NSZone *)zone [newQueue setDownloadProgressDelegate:[self downloadProgressDelegate]]; [newQueue setShouldCancelAllRequestsOnFailure:[self shouldCancelAllRequestsOnFailure]]; [newQueue setShowAccurateProgress:[self showAccurateProgress]]; - [newQueue setUserInfo:[[[self userInfo] copyWithZone:zone] autorelease]]; + [newQueue setUserInfo:[[self userInfo] copyWithZone:zone]]; return newQueue; } - -@synthesize requestsCount; -@synthesize bytesUploadedSoFar; -@synthesize totalBytesToUpload; -@synthesize bytesDownloadedSoFar; -@synthesize totalBytesToDownload; -@synthesize shouldCancelAllRequestsOnFailure; -@synthesize uploadProgressDelegate; -@synthesize downloadProgressDelegate; -@synthesize requestDidStartSelector; -@synthesize requestDidReceiveResponseHeadersSelector; -@synthesize requestWillRedirectSelector; -@synthesize requestDidFinishSelector; -@synthesize requestDidFailSelector; -@synthesize queueDidFinishSelector; -@synthesize delegate; -@synthesize showAccurateProgress; -@synthesize userInfo; @end diff --git a/Classes/ASIWebPageRequest/ASIWebPageRequest.m b/Classes/ASIWebPageRequest/ASIWebPageRequest.m index eccac6a8..d5d9cf76 100644 --- a/Classes/ASIWebPageRequest/ASIWebPageRequest.m +++ b/Classes/ASIWebPageRequest/ASIWebPageRequest.m @@ -58,11 +58,10 @@ - (id)initWithURL:(NSURL *)newURL - (void)dealloc { + self.parentRequest = nil; + self.resourceList = nil; [externalResourceQueue cancelAllOperations]; - [externalResourceQueue release]; - [resourceList release]; - [parentRequest release]; - [super dealloc]; + [super dealloc]; } // This is a bit of a hack @@ -79,7 +78,7 @@ - (void)markAsFinished // Again, we call the super implementation in finishedFetchingExternalResources:, or here if this download was not an HTML or CSS file - (void)requestFinished { - complete = NO; + _complete = NO; if ([self mainRequest] || [self didUseCachedResponse]) { [super requestFinished]; [super markAsFinished]; @@ -322,7 +321,7 @@ - (void)finishedFetchingExternalResources:(ASINetworkQueue *)queue if ([self downloadDestinationPath]) { parsedResponse = [NSMutableString stringWithContentsOfFile:[self downloadDestinationPath] encoding:[self responseEncoding] error:&err]; } else { - parsedResponse = [[[self responseString] mutableCopy] autorelease]; + parsedResponse = [[self responseString] mutableCopy]; } if (err) { [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:101 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"Error: unable to read response CSS from disk",NSLocalizedDescriptionKey,nil]]]; @@ -360,7 +359,7 @@ - (void)finishedFetchingExternalResources:(ASINetworkQueue *)queue if ([self downloadDestinationPath]) { // Truncate the file first - [[[[NSFileManager alloc] init] autorelease] createFileAtPath:[self downloadDestinationPath] contents:nil attributes:nil]; + [[[NSFileManager alloc] init] createFileAtPath:[self downloadDestinationPath] contents:nil attributes:nil]; saveContext = xmlSaveToFd([[NSFileHandle fileHandleForWritingAtPath:[self downloadDestinationPath]] fileDescriptor],NULL,2); // 2 == XML_SAVE_NO_DECL, this isn't declared on Mac OS 10.5 xmlSaveDoc(saveContext, doc); @@ -380,14 +379,14 @@ - (void)finishedFetchingExternalResources:(ASINetworkQueue *)queue saveContext = xmlSaveToBuffer(buffer,NULL,2); // 2 == XML_SAVE_NO_DECL, this isn't declared on Mac OS 10.5 xmlSaveDoc(saveContext, doc); xmlSaveClose(saveContext); - [self setRawResponseData:[[[NSMutableData alloc] initWithBytes:buffer->content length:buffer->use] autorelease]]; + [self setRawResponseData:[[NSMutableData alloc] initWithBytes:buffer->content length:buffer->use]]; xmlBufferFree(buffer); #endif } // Strip the content encoding if the original response was gzipped if ([self isResponseCompressed]) { - NSMutableDictionary *headers = [[[self responseHeaders] mutableCopy] autorelease]; + NSMutableDictionary *headers = [[self responseHeaders] mutableCopy]; [headers removeObjectForKey:@"Content-Encoding"]; [self setResponseHeaders:headers]; } @@ -404,10 +403,10 @@ - (void)finishedFetchingExternalResources:(ASINetworkQueue *)queue } } if (![self parentRequest]) { - [[self class] updateProgressIndicator:&downloadProgressDelegate withProgress:contentLength ofTotal:contentLength]; + [[self class] updateProgressIndicator:[self downloadProgressDelegate] withProgress:[self contentLength] ofTotal:[self contentLength]]; } - NSMutableDictionary *newHeaders = [[[self responseHeaders] mutableCopy] autorelease]; + NSMutableDictionary *newHeaders = [[self responseHeaders] mutableCopy]; [newHeaders removeObjectForKey:@"Content-Encoding"]; [self setResponseHeaders:newHeaders]; @@ -584,11 +583,11 @@ - (BOOL)respondsToSelector:(SEL)selector } //Ok, now check for selectors we want to pass on to the delegate if (selector == @selector(requestStarted:) || selector == @selector(request:didReceiveResponseHeaders:) || selector == @selector(request:willRedirectToURL:) || selector == @selector(requestFinished:) || selector == @selector(requestFailed:) || selector == @selector(request:didReceiveData:) || selector == @selector(authenticationNeededForRequest:) || selector == @selector(proxyAuthenticationNeededForRequest:)) { - return [delegate respondsToSelector:selector]; + return [[self delegate] respondsToSelector:selector]; } else if (selector == @selector(request:didReceiveBytes:) || selector == @selector(request:incrementDownloadSizeBy:)) { - return [downloadProgressDelegate respondsToSelector:selector]; + return [[self downloadProgressDelegate] respondsToSelector:selector]; } else if (selector == @selector(request:didSendBytes:) || selector == @selector(request:incrementUploadSizeBy:)) { - return [uploadProgressDelegate respondsToSelector:selector]; + return [[self uploadProgressDelegate] respondsToSelector:selector]; } return [super respondsToSelector:selector]; } @@ -599,11 +598,11 @@ - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector return [[self parentRequest] methodSignatureForSelector:selector]; } if (selector == @selector(requestStarted:) || selector == @selector(request:didReceiveResponseHeaders:) || selector == @selector(request:willRedirectToURL:) || selector == @selector(requestFinished:) || selector == @selector(requestFailed:) || selector == @selector(request:didReceiveData:) || selector == @selector(authenticationNeededForRequest:) || selector == @selector(proxyAuthenticationNeededForRequest:)) { - return [(id)delegate methodSignatureForSelector:selector]; + return [[(id)self delegate] methodSignatureForSelector:selector]; } else if (selector == @selector(request:didReceiveBytes:) || selector == @selector(request:incrementDownloadSizeBy:)) { - return [(id)downloadProgressDelegate methodSignatureForSelector:selector]; + return [[(id)self downloadProgressDelegate] methodSignatureForSelector:selector]; } else if (selector == @selector(request:didSendBytes:) || selector == @selector(request:incrementUploadSizeBy:)) { - return [(id)uploadProgressDelegate methodSignatureForSelector:selector]; + return [(id)[self uploadProgressDelegate] methodSignatureForSelector:selector]; } return nil; } @@ -615,11 +614,11 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation } SEL selector = [anInvocation selector]; if (selector == @selector(requestStarted:) || selector == @selector(request:didReceiveResponseHeaders:) || selector == @selector(request:willRedirectToURL:) || selector == @selector(requestFinished:) || selector == @selector(requestFailed:) || selector == @selector(request:didReceiveData:) || selector == @selector(authenticationNeededForRequest:) || selector == @selector(proxyAuthenticationNeededForRequest:)) { - [anInvocation invokeWithTarget:delegate]; + [anInvocation invokeWithTarget:[self delegate]]; } else if (selector == @selector(request:didReceiveBytes:) || selector == @selector(request:incrementDownloadSizeBy:)) { - [anInvocation invokeWithTarget:downloadProgressDelegate]; + [anInvocation invokeWithTarget:[self downloadProgressDelegate]]; } else if (selector == @selector(request:didSendBytes:) || selector == @selector(request:incrementUploadSizeBy:)) { - [anInvocation invokeWithTarget:uploadProgressDelegate]; + [anInvocation invokeWithTarget:[self uploadProgressDelegate]]; } } diff --git a/Classes/CloudFiles/ASICloudFilesCDNRequest.m b/Classes/CloudFiles/ASICloudFilesCDNRequest.m index 397a8273..697e23ec 100644 --- a/Classes/CloudFiles/ASICloudFilesCDNRequest.m +++ b/Classes/CloudFiles/ASICloudFilesCDNRequest.m @@ -39,7 +39,7 @@ + (id)containerInfoRequest:(NSString *)containerName { - (BOOL)cdnEnabled { NSNumber *enabled = [[self responseHeaders] objectForKey:@"X-CDN-Enabled"]; - if (!enabled) { + if (enabled == nil) { enabled = [[self responseHeaders] objectForKey:@"X-Cdn-Enabled"]; } return [enabled boolValue]; @@ -63,7 +63,7 @@ - (NSString *)cdnSSLURI { - (NSUInteger)cdnTTL { NSNumber *ttl = [[self responseHeaders] objectForKey:@"X-TTL"]; - if (!ttl) { + if (ttl == nil) { ttl = [[self responseHeaders] objectForKey:@"X-Ttl"]; } return [ttl intValue]; @@ -81,7 +81,7 @@ + (id)listRequestWithLimit:(NSUInteger)limit marker:(NSString *)marker enabledOn NSString *query = @"?format=xml"; if (limit > 0) { - query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]]; + query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", (int)limit]]; } if (marker) { @@ -89,7 +89,7 @@ + (id)listRequestWithLimit:(NSUInteger)limit marker:(NSString *)marker enabledOn } if (limit > 0) { - query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]]; + query = [query stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", (int)limit]]; } ASICloudFilesCDNRequest *request = [ASICloudFilesCDNRequest cdnRequestWithMethod:@"GET" query:query]; @@ -128,7 +128,7 @@ + (id)putRequestWithContainer:(NSString *)containerName { + (id)putRequestWithContainer:(NSString *)containerName ttl:(NSUInteger)ttl { ASICloudFilesCDNRequest *request = [ASICloudFilesCDNRequest cdnRequestWithMethod:@"PUT" containerName:containerName]; - [request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", ttl]]; + [request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", (int)ttl]]; return request; } @@ -148,7 +148,7 @@ + (id)postRequestWithContainer:(NSString *)containerName { + (id)postRequestWithContainer:(NSString *)containerName cdnEnabled:(BOOL)cdnEnabled ttl:(NSUInteger)ttl { ASICloudFilesCDNRequest *request = [ASICloudFilesCDNRequest cdnRequestWithMethod:@"POST" containerName:containerName]; if (ttl > 0) { - [request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", ttl]]; + [request addRequestHeader:@"X-Ttl" value:[NSString stringWithFormat:@"%i", (int)ttl]]; } [request addRequestHeader:@"X-CDN-Enabled" value:cdnEnabled ? @"True" : @"False"]; return request; diff --git a/Classes/CloudFiles/ASICloudFilesContainerRequest.m b/Classes/CloudFiles/ASICloudFilesContainerRequest.m index f6ed4ec5..c5fc98df 100644 --- a/Classes/CloudFiles/ASICloudFilesContainerRequest.m +++ b/Classes/CloudFiles/ASICloudFilesContainerRequest.m @@ -64,7 +64,7 @@ + (id)listRequestWithLimit:(NSUInteger)limit marker:(NSString *)marker { NSString *queryString = @"?format=xml"; if (limit > 0) { - queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]]; + queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", (int)limit]]; } if (marker != nil) { diff --git a/Classes/CloudFiles/ASICloudFilesObjectRequest.m b/Classes/CloudFiles/ASICloudFilesObjectRequest.m index 9d1600bf..d936fbab 100644 --- a/Classes/CloudFiles/ASICloudFilesObjectRequest.m +++ b/Classes/CloudFiles/ASICloudFilesObjectRequest.m @@ -74,7 +74,7 @@ + (NSString *)queryStringWithContainer:(NSString *)container limit:(NSUInteger)l NSString *queryString = @"?format=xml"; if (limit && limit > 0) { - queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", limit]]; + queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&limit=%i", (int)limit]]; } if (marker) { queryString = [queryString stringByAppendingString:[NSString stringWithFormat:@"&marker=%@", [marker stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; diff --git a/Classes/Tests/ASICloudFilesRequestTests.m b/Classes/Tests/ASICloudFilesRequestTests.m index d0c459da..7230d8f9 100644 --- a/Classes/Tests/ASICloudFilesRequestTests.m +++ b/Classes/Tests/ASICloudFilesRequestTests.m @@ -257,13 +257,13 @@ - (void)testPostObject { ASICloudFilesObject *object = [ASICloudFilesObject object]; object.name = @"infotestfile.txt"; object.metadata = metadata; - + [metadata release]; + ASICloudFilesObjectRequest *request = [ASICloudFilesObjectRequest postObjectRequestWithContainer:@"ASICloudFilesTest" object:object]; [request startSynchronous]; GHAssertTrue([request responseStatusCode] == 202, @"Failed to post object metadata"); - [metadata release]; } diff --git a/Classes/Tests/ASIFormDataRequestTests.m b/Classes/Tests/ASIFormDataRequestTests.m index f54ef990..24c59b6f 100644 --- a/Classes/Tests/ASIFormDataRequestTests.m +++ b/Classes/Tests/ASIFormDataRequestTests.m @@ -70,7 +70,7 @@ - (void)testPostWithFileUpload [request setFile:path forKey:@"file"]; [request startSynchronous]; - BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu\r\ncontent_type: %@",@"foo",d,v,@"bigfile",size,@"application/octet-stream"]]); + BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %u\r\ncontent_type: %@",@"foo",d,v,@"bigfile",size,@"application/octet-stream"]]); GHAssertTrue(success,@"Failed to upload the correct data (using local file)"); //Try the same with the raw data @@ -81,7 +81,7 @@ - (void)testPostWithFileUpload [request setData:data forKey:@"file"]; [request startSynchronous]; - success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu\r\ncontent_type: %@",@"foo",d,v,@"file",size,@"application/octet-stream"]]); + success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %u\r\ncontent_type: %@",@"foo",d,v,@"file",size,@"application/octet-stream"]]); GHAssertTrue(success,@"Failed to upload the correct data (using NSData)"); //Post with custom content-type and file name @@ -92,7 +92,7 @@ - (void)testPostWithFileUpload [request setFile:path withFileName:@"myfile" andContentType:@"text/plain" forKey:@"file"]; [request startSynchronous]; - success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu\r\ncontent_type: %@",@"foo",d,v,@"myfile",size,@"text/plain"]]); + success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %u\r\ncontent_type: %@",@"foo",d,v,@"myfile",size,@"text/plain"]]); GHAssertTrue(success,@"Failed to send the correct content-type / file name"); //Post raw data with custom content-type and file name @@ -103,7 +103,7 @@ - (void)testPostWithFileUpload [request setData:data withFileName:@"myfile" andContentType:@"text/plain" forKey:@"file"]; [request startSynchronous]; - success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %hu\r\ncontent_type: %@",@"foo",d,v,@"myfile",size,@"text/plain"]]); + success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"post_var: %@\r\npost_var2: %@\r\npost_var3: %@\r\nfile_name: %@\r\nfile_size: %u\r\ncontent_type: %@",@"foo",d,v,@"myfile",size,@"text/plain"]]); GHAssertTrue(success,@"Failed to send the correct content-type / file name"); } diff --git a/Classes/Tests/ASIHTTPRequestTests.m b/Classes/Tests/ASIHTTPRequestTests.m index d70df796..9362c4e6 100644 --- a/Classes/Tests/ASIHTTPRequestTests.m +++ b/Classes/Tests/ASIHTTPRequestTests.m @@ -436,15 +436,15 @@ - (void)testAutomaticRedirection if (i > 304 && i < 307) { continue; } - NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%hi",i]]; + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%i",i]]; request = [ASIHTTPRequest requestWithURL:url]; [request setShouldRedirect:NO]; [request startSynchronous]; if (i == 304) { // 304s will not contain a body, as per rfc2616. Will test 304 handling in a future test when we have etag support continue; } - success = [[request responseString] isEqualToString:[NSString stringWithFormat:@"Non-redirected content with %hi status code",i]]; - GHAssertTrue(success,[NSString stringWithFormat:@"Got the wrong content when not redirecting after a %hi",i]); + success = [[request responseString] isEqualToString:[NSString stringWithFormat:@"Non-redirected content with %u status code",i]]; + GHAssertTrue(success,[NSString stringWithFormat:@"Got the wrong content when not redirecting after a %u",i]); request2 = [ASIFormDataRequest requestWithURL:url]; [request2 setPostValue:@"Giant Monkey" forKey:@"lookbehindyou"]; @@ -454,13 +454,13 @@ - (void)testAutomaticRedirection if (i>304) { method = @"POST"; } - NSString *expectedString = [NSString stringWithFormat:@"Redirected as %@ after a %hi status code",method,i]; + NSString *expectedString = [NSString stringWithFormat:@"Redirected as %@ after a %u status code",method,i]; if (i>304) { expectedString = [NSString stringWithFormat:@"%@\r\nWatch out for the Giant Monkey!",expectedString]; } success = [[request2 responseString] isEqualToString:expectedString]; - GHAssertTrue(success,[NSString stringWithFormat:@"Got the wrong content when redirecting after a %hi",i]); + GHAssertTrue(success,[NSString stringWithFormat:@"Got the wrong content when redirecting after a %u",i]); success = ([request2 responseStatusCode] == 200); GHAssertTrue(success,@"Got the wrong status code (expected 200)"); @@ -470,7 +470,7 @@ - (void)testAutomaticRedirection // Test RFC 2616 behaviour for (i=301; i<303; i++) { - NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%hi",i]]; + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%u",i]]; request2 = [ASIFormDataRequest requestWithURL:url]; [request2 setPostValue:@"Giant Monkey" forKey:@"lookbehindyou"]; [request2 setShouldUseRFC2616RedirectBehaviour:YES]; @@ -483,14 +483,14 @@ - (void)testAutomaticRedirection success = ([request2 postLength] == 0 && ![request2 postBody] && [[request2 requestMethod] isEqualToString:@"GET"]); GHAssertTrue(success,@"Failed to reset request to GET on 303 redirect"); - success = [[request2 responseString] isEqualToString:[NSString stringWithFormat:@"Redirected as GET after a %hi status code",i]]; + success = [[request2 responseString] isEqualToString:[NSString stringWithFormat:@"Redirected as GET after a %u status code",i]]; GHAssertTrue(success,@"Failed to dump the post body on 303 redirect"); } else { success = ([request2 postLength] > 0 || ![request2 postBody] || ![[request2 requestMethod] isEqualToString:@"POST"]); GHAssertTrue(success,@"Failed to use the same request method and body for a redirect when using rfc2616 behaviour"); - success = ([[request2 responseString] isEqualToString:[NSString stringWithFormat:@"Redirected as POST after a %hi status code\r\nWatch out for the Giant Monkey!",i]]); + success = ([[request2 responseString] isEqualToString:[NSString stringWithFormat:@"Redirected as POST after a %u status code\r\nWatch out for the Giant Monkey!",i]]); GHAssertTrue(success,@"Failed to send the correct post body on redirect"); } } @@ -524,11 +524,11 @@ - (void)test30xCrash { int i; for (i=305; i<308; i++) { - ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%hi",i]]]; + ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%i",i]]]; [request setPostValue:@"foo" forKey:@"eep"]; [request setShouldRedirect:NO]; [request startSynchronous]; - request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%hi",i]]]; + request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://allseeing-i.com/ASIHTTPRequest/tests/redirect/%i",i]]]; [request setPostValue:@"foo" forKey:@"eep"]; [request startSynchronous]; } @@ -661,7 +661,7 @@ - (void)testUploadContentLength [request setPostBody:[NSMutableData dataWithLength:1024*32]]; [request startSynchronous]; - BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"%hu",(1024*32)]]); + BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"%d",(1024*32)]]); GHAssertTrue(success,@"Sent wrong content length"); } diff --git a/Classes/Tests/ASINetworkQueueTests.m b/Classes/Tests/ASINetworkQueueTests.m index 2fbee45e..d9697d2b 100755 --- a/Classes/Tests/ASINetworkQueueTests.m +++ b/Classes/Tests/ASINetworkQueueTests.m @@ -347,7 +347,7 @@ - (void)testUploadProgress int i; for (i=0; i<3; i++) { NSData *data = [[[NSMutableData alloc] initWithLength:fileSizes[i]*1024] autorelease]; - NSString *path = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%hi",i]]; + NSString *path = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%i",i]]; [data writeToFile:path atomically:NO]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [request setFile:path forKey:@"file"]; @@ -376,7 +376,7 @@ - (void)testUploadProgress for (i=0; i<3; i++) { NSData *data = [[[NSMutableData alloc] initWithLength:fileSizes[i]*1024] autorelease]; - NSString *path = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%hi",i]]; + NSString *path = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"file%i",i]]; [data writeToFile:path atomically:NO]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [request setFile:path forKey:@"file"]; diff --git a/Classes/Tests/ASIS3RequestTests.m b/Classes/Tests/ASIS3RequestTests.m index d747e01a..ba973a47 100644 --- a/Classes/Tests/ASIS3RequestTests.m +++ b/Classes/Tests/ASIS3RequestTests.m @@ -418,10 +418,10 @@ - (void)testListRequest // Firstly, create and upload 5 files int i; for (i=0; i<5; i++) { - NSString *text = [NSString stringWithFormat:@"This is the content of file #%hi",i]; - NSString *filePath = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"%hi.txt",i]]; + NSString *text = [NSString stringWithFormat:@"This is the content of file #%i",i]; + NSString *filePath = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"%i.txt",i]]; [[text dataUsingEncoding:NSUTF8StringEncoding] writeToFile:filePath atomically:NO]; - NSString *key = [NSString stringWithFormat:@"test-file/%hi",i]; + NSString *key = [NSString stringWithFormat:@"test-file/%i",i]; ASIS3ObjectRequest *request = [ASIS3ObjectRequest PUTRequestForFile:filePath withBucket:bucket key:key]; [request setSecretAccessKey:secretAccessKey]; [request setAccessKey:accessKey]; @@ -502,7 +502,7 @@ - (void)testListRequest i=0; // For each one, we'll just upload the same content again for (ASIS3BucketObject *object in [listRequest objects]) { - NSString *oldFilePath = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"%hi.txt",i]];; + NSString *oldFilePath = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"%i.txt",i]];; ASIS3Request *request = [object PUTRequestWithFile:oldFilePath]; [request setAccessKey:accessKey]; [request setSecretAccessKey:secretAccessKey]; @@ -641,7 +641,7 @@ - (void)testQueueProgress int i; for (i=0; i<5; i++) { - NSString *key = [NSString stringWithFormat:@"stuff/file%hi.txt",i+1]; + NSString *key = [NSString stringWithFormat:@"stuff/file%i.txt",i+1]; ASIS3ObjectRequest *s3Request = [ASIS3ObjectRequest PUTRequestForData:data withBucket:bucket key:key]; [s3Request setSecretAccessKey:secretAccessKey]; @@ -667,12 +667,12 @@ - (void)testQueueProgress for (i=0; i<5; i++) { - NSString *key = [NSString stringWithFormat:@"stuff/file%hi.txt",i+1]; + NSString *key = [NSString stringWithFormat:@"stuff/file%i.txt",i+1]; ASIS3ObjectRequest *s3Request = [ASIS3ObjectRequest requestWithBucket:bucket key:key]; [s3Request setSecretAccessKey:secretAccessKey]; [s3Request setAccessKey:accessKey]; - NSString *downloadPath = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"%hi.jpg",i+1]]; + NSString *downloadPath = [[self filePathForTemporaryTestFiles] stringByAppendingPathComponent:[NSString stringWithFormat:@"%i.jpg",i+1]]; [s3Request setDownloadDestinationPath:downloadPath]; [[self networkQueue] addOperation:s3Request]; } @@ -693,7 +693,7 @@ - (void)testQueueProgress for (i=0; i<5; i++) { - NSString *key = [NSString stringWithFormat:@"stuff/file%hi.txt",i+1]; + NSString *key = [NSString stringWithFormat:@"stuff/file%i.txt",i+1]; ASIS3ObjectRequest *s3Request = [ASIS3ObjectRequest DELETERequestWithBucket:bucket key:key]; [s3Request setSecretAccessKey:secretAccessKey]; diff --git a/Default-568h@2x.png b/Default-568h@2x.png new file mode 100644 index 00000000..0891b7aa Binary files /dev/null and b/Default-568h@2x.png differ diff --git a/External/Reachability/Reachability.h b/External/Reachability/Reachability.h index dc42472b..211b8166 100644 --- a/External/Reachability/Reachability.h +++ b/External/Reachability/Reachability.h @@ -1,194 +1,109 @@ /* - - File: Reachability.h - Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. - - Version: 2.0.4ddg - */ - -/* - Significant additions made by Andrew W. Donoho, August 11, 2009. - This is a derived work of Apple's Reachability v2.0 class. - - The below license is the new BSD license with the OSI recommended personalizations. - - - Extensions Copyright (C) 2009 Donoho Design Group, LLC. All Rights Reserved. + Copyright (c) 2011, Tony Million. + All rights reserved. Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Andrew W. Donoho nor Donoho Design Group, L.L.C. - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY DONOHO DESIGN GROUP, L.L.C. "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - */ - - -/* - - Apple's Original License on Reachability v2.0 - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. - ("Apple") in consideration of your agreement to the following terms, and your - use, installation, modification or redistribution of this Apple software - constitutes acceptance of these terms. If you do not agree with these terms, - please do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following terms, and subject - to these terms, Apple grants you a personal, non-exclusive license, under - Apple's copyrights in this original Apple software (the "Apple Software"), to - use, reproduce, modify and redistribute the Apple Software, with or without - modifications, in source and/or binary forms; provided that if you redistribute - the Apple Software in its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all such redistributions - of the Apple Software. - - Neither the name, trademarks, service marks or logos of Apple Inc. may be used - to endorse or promote products derived from the Apple Software without specific - prior written permission from Apple. Except as expressly stated in this notice, - no other rights or licenses, express or implied, are granted by Apple herein, - including but not limited to any patent rights that may be infringed by your - derivative works or by other works in which the Apple Software may be - incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO - WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED - WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN - COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR - DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF - CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF - APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Copyright (C) 2009 Apple Inc. All Rights Reserved. - - */ - - -/* - DDG extensions include: - Each reachability object now has a copy of the key used to store it in a - dictionary. This allows each observer to quickly determine if the event is - important to them. - - -currentReachabilityStatus also has a significantly different decision criteria than - Apple's code. - - A multiple convenience test methods have been added. + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ #import #import -#import - -#define USE_DDG_EXTENSIONS 1 // Use DDG's Extensions to test network criteria. -// Since NSAssert and NSCAssert are used in this code, -// I recommend you set NS_BLOCK_ASSERTIONS=1 in the release versions of your projects. - -enum { - - // DDG NetworkStatus Constant Names. - kNotReachable = 0, // Apple's code depends upon 'NotReachable' being the same value as 'NO'. - kReachableViaWWAN, // Switched order from Apple's enum. WWAN is active before WiFi. - kReachableViaWiFi - -}; -typedef uint32_t NetworkStatus; - -enum { - - // Apple NetworkStatus Constant Names. - NotReachable = kNotReachable, - ReachableViaWiFi = kReachableViaWiFi, - ReachableViaWWAN = kReachableViaWWAN - -}; +#import +#import +#import +#import +#import +#import + +/** + * Does ARC support GCD objects? + * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+ + * + * @see http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h + **/ +#if OS_OBJECT_USE_OBJC +#define NEEDS_DISPATCH_RETAIN_RELEASE 0 +#else +#define NEEDS_DISPATCH_RETAIN_RELEASE 1 +#endif + +/** + * Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X. + * + * @see http://nshipster.com/ns_enum-ns_options/ + **/ +#ifndef NS_ENUM +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#endif -extern NSString *const kInternetConnection; -extern NSString *const kLocalWiFiConnection; extern NSString *const kReachabilityChangedNotification; -@interface Reachability: NSObject { - -@private - NSString *key_; - SCNetworkReachabilityRef reachabilityRef; - -} +typedef NS_ENUM(NSInteger, NetworkStatus) { + // Apple NetworkStatus Compatible Names. + NotReachable = 0, + ReachableViaWiFi = 2, + ReachableViaWWAN = 1 +}; -@property (atomic, copy) NSString *key; // Atomic because network operations are asynchronous. +@class Reachability; -// Designated Initializer. -- (Reachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref; +typedef void (^NetworkReachable)(Reachability * reachability); +typedef void (^NetworkUnreachable)(Reachability * reachability); -// Use to check the reachability of a particular host name. -+ (Reachability *) reachabilityWithHostName: (NSString*) hostName; +@interface Reachability : NSObject -// Use to check the reachability of a particular IP address. -+ (Reachability *) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress; +@property (nonatomic, copy) NetworkReachable reachableBlock; +@property (nonatomic, copy) NetworkUnreachable unreachableBlock; -// Use to check whether the default route is available. -// Should be used to, at minimum, establish network connectivity. -+ (Reachability *) reachabilityForInternetConnection; -// Use to check whether a local wifi connection is available. -+ (Reachability *) reachabilityForLocalWiFi; +@property (nonatomic, assign) BOOL reachableOnWWAN; -//Start listening for reachability notifications on the current run loop. -- (BOOL) startNotifier; -- (void) stopNotifier; ++(Reachability*)reachabilityWithHostname:(NSString*)hostname; ++(Reachability*)reachabilityForInternetConnection; ++(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress; ++(Reachability*)reachabilityForLocalWiFi; -// Comparison routines to enable choosing actions in a notification. -- (BOOL) isEqual: (Reachability *) r; +-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref; -// These are the status tests. -- (NetworkStatus) currentReachabilityStatus; +-(BOOL)startNotifier; +-(void)stopNotifier; -// The main direct test of reachability. -- (BOOL) isReachable; +-(BOOL)isReachable; +-(BOOL)isReachableViaWWAN; +-(BOOL)isReachableViaWiFi; // WWAN may be available, but not active until a connection has been established. // WiFi may require a connection for VPN on Demand. -- (BOOL) isConnectionRequired; // Identical DDG variant. -- (BOOL) connectionRequired; // Apple's routine. - +-(BOOL)isConnectionRequired; // Identical DDG variant. +-(BOOL)connectionRequired; // Apple's routine. // Dynamic, on demand connection? -- (BOOL) isConnectionOnDemand; - +-(BOOL)isConnectionOnDemand; // Is user intervention required? -- (BOOL) isInterventionRequired; - -// Routines for specific connection testing by your app. -- (BOOL) isReachableViaWWAN; -- (BOOL) isReachableViaWiFi; +-(BOOL)isInterventionRequired; -- (SCNetworkReachabilityFlags) reachabilityFlags; +-(NetworkStatus)currentReachabilityStatus; +-(SCNetworkReachabilityFlags)reachabilityFlags; +-(NSString*)currentReachabilityString; +-(NSString*)currentReachabilityFlags; @end diff --git a/External/Reachability/Reachability.m b/External/Reachability/Reachability.m index 8648ea69..99aa9f52 100644 --- a/External/Reachability/Reachability.m +++ b/External/Reachability/Reachability.m @@ -1,814 +1,527 @@ /* - - File: Reachability.m - Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. - - Version: 2.0.4ddg - */ - -/* - Significant additions made by Andrew W. Donoho, August 11, 2009. - This is a derived work of Apple's Reachability v2.0 class. - - The below license is the new BSD license with the OSI recommended personalizations. - - - Extensions Copyright (C) 2009 Donoho Design Group, LLC. All Rights Reserved. + Copyright (c) 2011, Tony Million. + All rights reserved. Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + modification, are permitted provided that the following conditions are met: - * Neither the name of Andrew W. Donoho nor Donoho Design Group, L.L.C. - may be used to endorse or promote products derived from this software - without specific prior written permission. + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. - THIS SOFTWARE IS PROVIDED BY DONOHO DESIGN GROUP, L.L.C. "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ +#import "Reachability.h" -/* - - Apple's Original License on Reachability v2.0 - - Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. - ("Apple") in consideration of your agreement to the following terms, and your - use, installation, modification or redistribution of this Apple software - constitutes acceptance of these terms. If you do not agree with these terms, - please do not use, install, modify or redistribute this Apple software. - - In consideration of your agreement to abide by the following terms, and subject - to these terms, Apple grants you a personal, non-exclusive license, under - Apple's copyrights in this original Apple software (the "Apple Software"), to - use, reproduce, modify and redistribute the Apple Software, with or without - modifications, in source and/or binary forms; provided that if you redistribute - the Apple Software in its entirety and without modifications, you must retain - this notice and the following text and disclaimers in all such redistributions - of the Apple Software. - - Neither the name, trademarks, service marks or logos of Apple Inc. may be used - to endorse or promote products derived from the Apple Software without specific - prior written permission from Apple. Except as expressly stated in this notice, - no other rights or licenses, express or implied, are granted by Apple herein, - including but not limited to any patent rights that may be infringed by your - derivative works or by other works in which the Apple Software may be - incorporated. - - The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO - WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED - WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN - COMBINATION WITH YOUR PRODUCTS. - - IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR - DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF - CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF - APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Copyright (C) 2009 Apple Inc. All Rights Reserved. - -*/ - -/* - Each reachability object now has a copy of the key used to store it in a dictionary. - This allows each observer to quickly determine if the event is important to them. -*/ - -#import -#import -#import -#import -#import -#import - -#import -#import "Reachability.h" +NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification"; -NSString *const kInternetConnection = @"InternetConnection"; -NSString *const kLocalWiFiConnection = @"LocalWiFiConnection"; -NSString *const kReachabilityChangedNotification = @"NetworkReachabilityChangedNotification"; +@interface Reachability () -#define CLASS_DEBUG 1 // Turn on logReachabilityFlags. Must also have a project wide defined DEBUG. +@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef; -#if (defined DEBUG && defined CLASS_DEBUG) -#define logReachabilityFlags(flags) (logReachabilityFlags_(__PRETTY_FUNCTION__, __LINE__, flags)) -static NSString *reachabilityFlags_(SCNetworkReachabilityFlags flags) { - -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 30000) // Apple advises you to use the magic number instead of a symbol. - return [NSString stringWithFormat:@"Reachability Flags: %c%c %c%c%c%c%c%c%c", - (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', - (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', - - (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', - (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', - (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', - (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', - (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-']; +#if NEEDS_DISPATCH_RETAIN_RELEASE +@property (nonatomic, assign) dispatch_queue_t reachabilitySerialQueue; #else - // Compile out the v3.0 features for v2.2.1 deployment. - return [NSString stringWithFormat:@"Reachability Flags: %c%c %c%c%c%c%c%c", - (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', - (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', - - (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', - (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', - (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', - // v3 kSCNetworkReachabilityFlagsConnectionOnTraffic == v2 kSCNetworkReachabilityFlagsConnectionAutomatic - (flags & kSCNetworkReachabilityFlagsConnectionAutomatic) ? 'C' : '-', - // (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', // No v2 equivalent. - (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', - (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-']; +@property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue; #endif - -} // reachabilityFlags_() -static void logReachabilityFlags_(const char *name, int line, SCNetworkReachabilityFlags flags) { - - NSLog(@"%s (%d) \n\t%@", name, line, reachabilityFlags_(flags)); - -} // logReachabilityFlags_() -#define logNetworkStatus(status) (logNetworkStatus_(__PRETTY_FUNCTION__, __LINE__, status)) +@property (nonatomic, strong) id reachabilityObject; -static void logNetworkStatus_(const char *name, int line, NetworkStatus status) { - - NSString *statusString = nil; - - switch (status) { - case kNotReachable: - statusString = @"Not Reachable"; - break; - case kReachableViaWWAN: - statusString = @"Reachable via WWAN"; - break; - case kReachableViaWiFi: - statusString = @"Reachable via WiFi"; - break; - } - - NSLog(@"%s (%d) \n\tNetwork Status: %@", name, line, statusString); - -} // logNetworkStatus_() +-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags; +-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags; + +@end +static NSString *reachabilityFlags(SCNetworkReachabilityFlags flags) +{ + return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c", +#if TARGET_OS_IPHONE + (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', #else -#define logReachabilityFlags(flags) -#define logNetworkStatus(status) + 'X', #endif + (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', + (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', + (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', + (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', + (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-']; +} -@interface Reachability (private) - -- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags; +// Start listening for reachability notifications on the current run loop +static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) +{ +#pragma unused (target) +#if __has_feature(objc_arc) + Reachability *reachability = ((__bridge Reachability*)info); +#else + Reachability *reachability = ((Reachability*)info); +#endif + + // We probably don't need an autoreleasepool here, as GCD docs state each queue has its own autorelease pool, + // but what the heck eh? + @autoreleasepool + { + [reachability reachabilityChanged:flags]; + } +} -@end @implementation Reachability -@synthesize key = key_; +@synthesize reachabilityRef; +@synthesize reachabilitySerialQueue; -// Preclude direct access to ivars. -+ (BOOL) accessInstanceVariablesDirectly { - - return NO; +@synthesize reachableOnWWAN; -} // accessInstanceVariablesDirectly +@synthesize reachableBlock; +@synthesize unreachableBlock; +@synthesize reachabilityObject; -- (void) dealloc { - - [self stopNotifier]; - if(reachabilityRef) { - - CFRelease(reachabilityRef); reachabilityRef = NULL; - - } - - self.key = nil; - - [super dealloc]; - -} // dealloc +#pragma mark - Class Constructor Methods ++(Reachability*)reachabilityWithHostName:(NSString*)hostname +{ + return [Reachability reachabilityWithHostname:hostname]; +} -- (Reachability *) initWithReachabilityRef: (SCNetworkReachabilityRef) ref ++(Reachability*)reachabilityWithHostname:(NSString*)hostname { - self = [super init]; - if (self != nil) + SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]); + if (ref) { - reachabilityRef = ref; - } - - return self; - -} // initWithReachabilityRef: + id reachability = [[self alloc] initWithReachabilityRef:ref]; - -#if (defined DEBUG && defined CLASS_DEBUG) -- (NSString *) description { - - NSAssert(reachabilityRef, @"-description called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - - SCNetworkReachabilityGetFlags(reachabilityRef, &flags); - - return [NSString stringWithFormat: @"%@\n\t%@", self.key, reachabilityFlags_(flags)]; - -} // description +#if __has_feature(objc_arc) + return reachability; +#else + return [reachability autorelease]; #endif + } + + return nil; +} -#pragma mark - -#pragma mark Notification Management Methods - - -//Start listening for reachability notifications on the current run loop -static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) { - - #pragma unused (target, flags) - NSCAssert(info, @"info was NULL in ReachabilityCallback"); - NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was the wrong class in ReachabilityCallback"); - - //We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively - // in case someone uses the Reachablity object in a different thread. - NSAutoreleasePool* pool = [NSAutoreleasePool new]; - - // Post a notification to notify the client that the network reachability changed. - [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification - object: (Reachability *) info]; - - [pool release]; - -} // ReachabilityCallback() - - -- (BOOL) startNotifier { - - SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL}; - - if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context)) { - - if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { - - return YES; - - } - - } - - return NO; - -} // startNotifier - - -- (void) stopNotifier { - - if(reachabilityRef) { - - SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - - } - -} // stopNotifier - ++(Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress +{ + SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress); + if (ref) + { + id reachability = [[self alloc] initWithReachabilityRef:ref]; + +#if __has_feature(objc_arc) + return reachability; +#else + return [reachability autorelease]; +#endif + } + + return nil; +} -- (BOOL) isEqual: (Reachability *) r { - - return [r.key isEqualToString: self.key]; - -} // isEqual: ++(Reachability *)reachabilityForInternetConnection +{ + struct sockaddr_in zeroAddress; + bzero(&zeroAddress, sizeof(zeroAddress)); + zeroAddress.sin_len = sizeof(zeroAddress); + zeroAddress.sin_family = AF_INET; + + return [self reachabilityWithAddress:&zeroAddress]; +} ++(Reachability*)reachabilityForLocalWiFi +{ + struct sockaddr_in localWifiAddress; + bzero(&localWifiAddress, sizeof(localWifiAddress)); + localWifiAddress.sin_len = sizeof(localWifiAddress); + localWifiAddress.sin_family = AF_INET; + // IN_LINKLOCALNETNUM is defined in as 169.254.0.0 + localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); + + return [self reachabilityWithAddress:&localWifiAddress]; +} -#pragma mark - -#pragma mark Reachability Allocation Methods +// Initialization methods -+ (Reachability *) reachabilityWithHostName: (NSString *) hostName { - - SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]); - - if (ref) { - - Reachability *r = [[[self alloc] initWithReachabilityRef: ref] autorelease]; - - r.key = hostName; - - return r; - - } - - return nil; - -} // reachabilityWithHostName +-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref +{ + self = [super init]; + if (self != nil) + { + self.reachableOnWWAN = YES; + self.reachabilityRef = ref; + } + + return self; +} +-(void)dealloc +{ + [self stopNotifier]; -+ (NSString *) makeAddressKey: (in_addr_t) addr { - // addr is assumed to be in network byte order. - - static const int highShift = 24; - static const int highMidShift = 16; - static const int lowMidShift = 8; - static const in_addr_t mask = 0x000000ff; - - addr = ntohl(addr); - - return [NSString stringWithFormat: @"%d.%d.%d.%d", - (addr >> highShift) & mask, - (addr >> highMidShift) & mask, - (addr >> lowMidShift) & mask, - addr & mask]; - -} // makeAddressKey: + if(self.reachabilityRef) + { + CFRelease(self.reachabilityRef); + self.reachabilityRef = nil; + } + + self.reachableBlock = nil; + self.unreachableBlock = nil; + +#if !(__has_feature(objc_arc)) + [super dealloc]; +#endif + +} -+ (Reachability *) reachabilityWithAddress: (const struct sockaddr_in *) hostAddress { - - SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress); - - if (ref) { - - Reachability *r = [[[self alloc] initWithReachabilityRef: ref] autorelease]; - - r.key = [self makeAddressKey: hostAddress->sin_addr.s_addr]; - - return r; - - } - - return nil; +#pragma mark - Notifier Methods -} // reachabilityWithAddress +// Notifier +// NOTE: This uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD +// - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS. +// INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want) +-(BOOL)startNotifier +{ + SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL }; + + // this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves + // woah + self.reachabilityObject = self; + + + + // First, we need to create a serial queue. + // We allocate this once for the lifetime of the notifier. + self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL); + if(!self.reachabilitySerialQueue) + { + return NO; + } + +#if __has_feature(objc_arc) + context.info = (__bridge void *)self; +#else + context.info = (void *)self; +#endif + + if (!SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context)) + { +#ifdef DEBUG + NSLog(@"SCNetworkReachabilitySetCallback() failed: %s", SCErrorString(SCError())); +#endif + + // Clear out the dispatch queue + if(self.reachabilitySerialQueue) + { +#if NEEDS_DISPATCH_RETAIN_RELEASE + dispatch_release(self.reachabilitySerialQueue); +#endif + self.reachabilitySerialQueue = nil; + } + + self.reachabilityObject = nil; + + return NO; + } + + // Set it as our reachability queue, which will retain the queue + if(!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue)) + { +#ifdef DEBUG + NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError())); +#endif -+ (Reachability *) reachabilityForInternetConnection { - - struct sockaddr_in zeroAddress; - bzero(&zeroAddress, sizeof(zeroAddress)); - zeroAddress.sin_len = sizeof(zeroAddress); - zeroAddress.sin_family = AF_INET; + // UH OH - FAILURE! + + // First stop, any callbacks! + SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL); + + // Then clear out the dispatch queue. + if(self.reachabilitySerialQueue) + { +#if NEEDS_DISPATCH_RETAIN_RELEASE + dispatch_release(self.reachabilitySerialQueue); +#endif + self.reachabilitySerialQueue = nil; + } + + self.reachabilityObject = nil; + + return NO; + } + + return YES; +} - Reachability *r = [self reachabilityWithAddress: &zeroAddress]; +-(void)stopNotifier +{ + // First stop, any callbacks! + SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL); + + // Unregister target from the GCD serial dispatch queue. + SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL); + + if(self.reachabilitySerialQueue) + { +#if NEEDS_DISPATCH_RETAIN_RELEASE + dispatch_release(self.reachabilitySerialQueue); +#endif + self.reachabilitySerialQueue = nil; + } + + self.reachabilityObject = nil; +} - r.key = kInternetConnection; - - return r; +#pragma mark - reachability tests -} // reachabilityForInternetConnection +// This is for the case where you flick the airplane mode; +// you end up getting something like this: +//Reachability: WR ct----- +//Reachability: -- ------- +//Reachability: WR ct----- +//Reachability: -- ------- +// We treat this as 4 UNREACHABLE triggers - really apple should do better than this +#define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection) -+ (Reachability *) reachabilityForLocalWiFi { - - struct sockaddr_in localWifiAddress; - bzero(&localWifiAddress, sizeof(localWifiAddress)); - localWifiAddress.sin_len = sizeof(localWifiAddress); - localWifiAddress.sin_family = AF_INET; - // IN_LINKLOCALNETNUM is defined in as 169.254.0.0 - localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); - - Reachability *r = [self reachabilityWithAddress: &localWifiAddress]; - - r.key = kLocalWiFiConnection; - - return r; - -} // reachabilityForLocalWiFi - - -#pragma mark - -#pragma mark Network Flag Handling Methods - - -#if USE_DDG_EXTENSIONS -// -// iPhone condition codes as reported by a 3GS running iPhone OS v3.0. -// Airplane Mode turned on: Reachability Flag Status: -- ------- -// WWAN Active: Reachability Flag Status: WR -t----- -// WWAN Connection required: Reachability Flag Status: WR ct----- -// WiFi turned on: Reachability Flag Status: -R ------- Reachable. -// Local WiFi turned on: Reachability Flag Status: -R xxxxxxd Reachable. -// WiFi turned on: Reachability Flag Status: -R ct----- Connection down. (Non-intuitive, empirically determined answer.) -const SCNetworkReachabilityFlags kConnectionDown = kSCNetworkReachabilityFlagsConnectionRequired | - kSCNetworkReachabilityFlagsTransientConnection; -// WiFi turned on: Reachability Flag Status: -R ct-i--- Reachable but it will require user intervention (e.g. enter a WiFi password). -// WiFi turned on: Reachability Flag Status: -R -t----- Reachable via VPN. -// -// In the below method, an 'x' in the flag status means I don't care about its value. -// -// This method differs from Apple's by testing explicitly for empirically observed values. -// This gives me more confidence in it's correct behavior. Apple's code covers more cases -// than mine. My code covers the cases that occur. -// -- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags { - - if (flags & kSCNetworkReachabilityFlagsReachable) { - - // Local WiFi -- Test derived from Apple's code: -localWiFiStatusForFlags:. - if (self.key == kLocalWiFiConnection) { - - // Reachability Flag Status: xR xxxxxxd Reachable. - return (flags & kSCNetworkReachabilityFlagsIsDirect) ? kReachableViaWiFi : kNotReachable; - - } - - // Observed WWAN Values: - // WWAN Active: Reachability Flag Status: WR -t----- - // WWAN Connection required: Reachability Flag Status: WR ct----- - // - // Test Value: Reachability Flag Status: WR xxxxxxx - if (flags & kSCNetworkReachabilityFlagsIsWWAN) { return kReachableViaWWAN; } - - // Clear moot bits. - flags &= ~(uint32_t)kSCNetworkReachabilityFlagsReachable; - flags &= ~(uint32_t)kSCNetworkReachabilityFlagsIsDirect; - flags &= ~(uint32_t)kSCNetworkReachabilityFlagsIsLocalAddress; // kInternetConnection is local. - - // Reachability Flag Status: -R ct---xx Connection down. - if (flags == kConnectionDown) { return kNotReachable; } - - // Reachability Flag Status: -R -t---xx Reachable. WiFi + VPN(is up) (Thank you Ling Wang) - if (flags & kSCNetworkReachabilityFlagsTransientConnection) { return kReachableViaWiFi; } - - // Reachability Flag Status: -R -----xx Reachable. - if (flags == 0) { return kReachableViaWiFi; } - - // Apple's code tests for dynamic connection types here. I don't. - // If a connection is required, regardless of whether it is on demand or not, it is a WiFi connection. - // If you care whether a connection needs to be brought up, use -isConnectionRequired. - // If you care about whether user intervention is necessary, use -isInterventionRequired. - // If you care about dynamically establishing the connection, use -isConnectionIsOnDemand. - - // Reachability Flag Status: -R cxxxxxx Reachable. - if (flags & kSCNetworkReachabilityFlagsConnectionRequired) { return kReachableViaWiFi; } - - // Required by the compiler. Should never get here. Default to not connected. -#if (defined DEBUG && defined CLASS_DEBUG) - NSAssert1(NO, @"Uncaught reachability test. Flags: %@", reachabilityFlags_(flags)); +-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags +{ + BOOL connectionUP = YES; + + if(!(flags & kSCNetworkReachabilityFlagsReachable)) + connectionUP = NO; + + if( (flags & testcase) == testcase ) + connectionUP = NO; + +#if TARGET_OS_IPHONE + if(flags & kSCNetworkReachabilityFlagsIsWWAN) + { + // We're on 3G. + if(!self.reachableOnWWAN) + { + // We don't want to connect when on 3G. + connectionUP = NO; + } + } #endif - return kNotReachable; - - } - - // Reachability Flag Status: x- xxxxxxx - return kNotReachable; - -} // networkStatusForFlags: - + + return connectionUP; +} -- (NetworkStatus) currentReachabilityStatus { - - NSAssert(reachabilityRef, @"currentReachabilityStatus called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - NetworkStatus status = kNotReachable; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - -// logReachabilityFlags(flags); - - status = [self networkStatusForFlags: flags]; - - return status; - - } - - return kNotReachable; - -} // currentReachabilityStatus +-(BOOL)isReachable +{ + SCNetworkReachabilityFlags flags; + + if(!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags)) + return NO; + + return [self isReachableWithFlags:flags]; +} +-(BOOL)isReachableViaWWAN +{ +#if TARGET_OS_IPHONE -- (BOOL) isReachable { - - NSAssert(reachabilityRef, @"isReachable called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - NetworkStatus status = kNotReachable; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - -// logReachabilityFlags(flags); + SCNetworkReachabilityFlags flags = 0; + + if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) + { + // Check we're REACHABLE + if(flags & kSCNetworkReachabilityFlagsReachable) + { + // Now, check we're on WWAN + if(flags & kSCNetworkReachabilityFlagsIsWWAN) + { + return YES; + } + } + } +#endif + + return NO; +} - status = [self networkStatusForFlags: flags]; +-(BOOL)isReachableViaWiFi +{ + SCNetworkReachabilityFlags flags = 0; + + if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) + { + // Check we're reachable + if((flags & kSCNetworkReachabilityFlagsReachable)) + { +#if TARGET_OS_IPHONE + // Check we're NOT on WWAN + if((flags & kSCNetworkReachabilityFlagsIsWWAN)) + { + return NO; + } +#endif + return YES; + } + } + + return NO; +} -// logNetworkStatus(status); - - return (kNotReachable != status); - - } - - return NO; - -} // isReachable +// WWAN may be available, but not active until a connection has been established. +// WiFi may require a connection for VPN on Demand. +-(BOOL)isConnectionRequired +{ + return [self connectionRequired]; +} -- (BOOL) isConnectionRequired { - - NSAssert(reachabilityRef, @"isConnectionRequired called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags; +-(BOOL)connectionRequired +{ + SCNetworkReachabilityFlags flags; - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - + if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) + { return (flags & kSCNetworkReachabilityFlagsConnectionRequired); - } - - return NO; - -} // isConnectionRequired - - -- (BOOL) connectionRequired { - - return [self isConnectionRequired]; - -} // connectionRequired -#endif - - -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 30000) -static const SCNetworkReachabilityFlags kOnDemandConnection = kSCNetworkReachabilityFlagsConnectionOnTraffic | - kSCNetworkReachabilityFlagsConnectionOnDemand; -#else -static const SCNetworkReachabilityFlags kOnDemandConnection = kSCNetworkReachabilityFlagsConnectionAutomatic; -#endif + + return NO; +} -- (BOOL) isConnectionOnDemand { - - NSAssert(reachabilityRef, @"isConnectionIsOnDemand called with NULL reachabilityRef"); - +// Dynamic, on demand connection? +-(BOOL)isConnectionOnDemand +{ SCNetworkReachabilityFlags flags; - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - + if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) + { return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) && - (flags & kOnDemandConnection)); - + (flags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand))); } return NO; - -} // isConnectionOnDemand - +} -- (BOOL) isInterventionRequired { - - NSAssert(reachabilityRef, @"isInterventionRequired called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags; +// Is user intervention required? +-(BOOL)isInterventionRequired +{ + SCNetworkReachabilityFlags flags; - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - + if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) + { return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) && (flags & kSCNetworkReachabilityFlagsInterventionRequired)); - } return NO; - -} // isInterventionRequired - - -- (BOOL) isReachableViaWWAN { - - NSAssert(reachabilityRef, @"isReachableViaWWAN called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - NetworkStatus status = kNotReachable; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - - status = [self networkStatusForFlags: flags]; - - return (kReachableViaWWAN == status); - - } - - return NO; - -} // isReachableViaWWAN - - -- (BOOL) isReachableViaWiFi { - - NSAssert(reachabilityRef, @"isReachableViaWiFi called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - NetworkStatus status = kNotReachable; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - - status = [self networkStatusForFlags: flags]; - - return (kReachableViaWiFi == status); - - } - - return NO; - -} // isReachableViaWiFi - - -- (SCNetworkReachabilityFlags) reachabilityFlags { - - NSAssert(reachabilityRef, @"reachabilityFlags called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - - return flags; - - } - - return 0; - -} // reachabilityFlags - - -#pragma mark - -#pragma mark Apple's Network Flag Handling Methods +} -#if !USE_DDG_EXTENSIONS -/* - * - * Apple's Network Status testing code. - * The only changes that have been made are to use the new logReachabilityFlags macro and - * test for local WiFi via the key instead of Apple's boolean. Also, Apple's code was for v3.0 only - * iPhone OS. v2.2.1 and earlier conditional compiling is turned on. Hence, to mirror Apple's behavior, - * set your Base SDK to v3.0 or higher. - * - */ +#pragma mark - reachability status stuff -- (NetworkStatus) localWiFiStatusForFlags: (SCNetworkReachabilityFlags) flags +-(NetworkStatus)currentReachabilityStatus { - logReachabilityFlags(flags); - - BOOL retVal = NotReachable; - if((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) - { - retVal = ReachableViaWiFi; - } - return retVal; + if([self isReachable]) + { + if([self isReachableViaWiFi]) + return ReachableViaWiFi; + +#if TARGET_OS_IPHONE + return ReachableViaWWAN; +#endif + } + + return NotReachable; } +-(SCNetworkReachabilityFlags)reachabilityFlags +{ + SCNetworkReachabilityFlags flags = 0; + + if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) + { + return flags; + } + + return 0; +} -- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags +-(NSString*)currentReachabilityString { - logReachabilityFlags(flags); - if (!(flags & kSCNetworkReachabilityFlagsReachable)) - { - // if target host is not reachable - return NotReachable; - } + NetworkStatus temp = [self currentReachabilityStatus]; - BOOL retVal = NotReachable; - - if (!(flags & kSCNetworkReachabilityFlagsConnectionRequired)) + if(temp == reachableOnWWAN) { - // if target host is reachable and no connection is required - // then we'll assume (for now) that your on Wi-Fi - retVal = ReachableViaWiFi; + // Updated for the fact that we have CDMA phones now! + return NSLocalizedString(@"Cellular", @""); } - -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 30000) // Apple advises you to use the magic number instead of a symbol. - if ((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) || - (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic)) -#else - if (flags & kSCNetworkReachabilityFlagsConnectionAutomatic) -#endif - { - // ... and the connection is on-demand (or on-traffic) if the - // calling application is using the CFSocketStream or higher APIs - - if (!(flags & kSCNetworkReachabilityFlagsInterventionRequired)) - { - // ... and no [user] intervention is needed - retVal = ReachableViaWiFi; - } - } - - if (flags & kSCNetworkReachabilityFlagsIsWWAN) + if (temp == ReachableViaWiFi) { - // ... but WWAN connections are OK if the calling application - // is using the CFNetwork (CFSocketStream?) APIs. - retVal = ReachableViaWWAN; + return NSLocalizedString(@"WiFi", @""); } - return retVal; + + return NSLocalizedString(@"No Connection", @""); } - -- (NetworkStatus) currentReachabilityStatus +-(NSString*)currentReachabilityFlags { - NSAssert(reachabilityRef, @"currentReachabilityStatus called with NULL reachabilityRef"); - - NetworkStatus retVal = NotReachable; - SCNetworkReachabilityFlags flags; - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - if(self.key == kLocalWiFiConnection) - { - retVal = [self localWiFiStatusForFlags: flags]; - } - else - { - retVal = [self networkStatusForFlags: flags]; - } - } - return retVal; + return reachabilityFlags([self reachabilityFlags]); } +#pragma mark - Callback function calls this method -- (BOOL) isReachable { - - NSAssert(reachabilityRef, @"isReachable called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags = 0; - NetworkStatus status = kNotReachable; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - - if(self.key == kLocalWiFiConnection) { - - status = [self localWiFiStatusForFlags: flags]; - - } else { - - status = [self networkStatusForFlags: flags]; - - } - - return (kNotReachable != status); - - } - - return NO; - -} // isReachable - - -- (BOOL) isConnectionRequired { - - return [self connectionRequired]; - -} // isConnectionRequired +-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags +{ + if([self isReachableWithFlags:flags]) + { + if(self.reachableBlock) + { + self.reachableBlock(self); + } + } + else + { + if(self.unreachableBlock) + { + self.unreachableBlock(self); + } + } + + // this makes sure the change notification happens on the MAIN THREAD + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification + object:self]; + }); +} +#pragma mark - Debug Description -- (BOOL) connectionRequired { - - NSAssert(reachabilityRef, @"connectionRequired called with NULL reachabilityRef"); - - SCNetworkReachabilityFlags flags; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) { - - logReachabilityFlags(flags); - - return (flags & kSCNetworkReachabilityFlagsConnectionRequired); - - } - - return NO; - -} // connectionRequired -#endif +- (NSString *) description +{ + NSString *description = [NSString stringWithFormat:@"<%@: %#x>", + NSStringFromClass([self class]), (unsigned int) self]; + return description; +} @end diff --git a/Mac Sample/English.lproj/MainMenu.xib b/Mac Sample/English.lproj/MainMenu.xib index a4659bb5..b48b0ea0 100644 --- a/Mac Sample/English.lproj/MainMenu.xib +++ b/Mac Sample/English.lproj/MainMenu.xib @@ -1,5874 +1,1039 @@ - - - 1050 - 11A511 - 1617 - 1138 - 566.00 - - YES - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - YES - 1617 - 518 - - - - YES - NSTextView - WebView - NSMenu - NSButton - NSCustomObject - NSImageView - NSImageCell - NSTableView - NSTextField - NSWindowTemplate - NSTextFieldCell - NSButtonCell - NSTableColumn - NSView - NSScrollView - NSTabViewItem - NSProgressIndicator - NSScroller - NSMenuItem - NSTabView - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - YES - - YES - - - - - YES - - NSApplication - - - FirstResponder - - - NSApplication - - - AMainMenu - - YES - - - NewApplication - - 1048576 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - submenuAction: - - NewApplication - - YES - - - About NewApplication - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Preferences… - , - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Services - - 1048576 - 2147483647 - - - submenuAction: - - Services - - YES - - _NSServicesMenu - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Hide NewApplication - h - 1048576 - 2147483647 - - - - - - Hide Others - h - 1572864 - 2147483647 - - - - - - Show All - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Quit NewApplication - q - 1048576 - 2147483647 - - - - - _NSAppleMenu - - - - - File - - 1048576 - 2147483647 - - - submenuAction: - - File - - YES - - - New - n - 1048576 - 2147483647 - - - - - - Open… - o - 1048576 - 2147483647 - - - - - - Open Recent - - 1048576 - 2147483647 - - - submenuAction: - - Open Recent - - YES - - - Clear Menu - - 1048576 - 2147483647 - - - - - _NSRecentDocumentsMenu - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Close - w - 1048576 - 2147483647 - - - - - - Save - s - 1048576 - 2147483647 - - - - - - Save As… - S - 1179648 - 2147483647 - - - - - - Revert to Saved - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Page Setup... - P - 1179648 - 2147483647 - - - - - - - Print… - p - 1048576 - 2147483647 - - - - - - - - - Edit - - 1048576 - 2147483647 - - - submenuAction: - - Edit - - YES - - - Undo - z - 1048576 - 2147483647 - - - - - - Redo - Z - 1179648 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Cut - x - 1048576 - 2147483647 - - - - - - Copy - c - 1048576 - 2147483647 - - - - - - Paste - v - 1048576 - 2147483647 - - - - - - Delete - - 1048576 - 2147483647 - - - - - - Select All - a - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Find - - 1048576 - 2147483647 - - - submenuAction: - - Find - - YES - - - Find… - f - 1048576 - 2147483647 - - - 1 - - - - Find Next - g - 1048576 - 2147483647 - - - 2 - - - - Find Previous - G - 1179648 - 2147483647 - - - 3 - - - - Use Selection for Find - e - 1048576 - 2147483647 - - - 7 - - - - Jump to Selection - j - 1048576 - 2147483647 - - - - - - - - - Spelling and Grammar - - 1048576 - 2147483647 - - - submenuAction: - - Spelling and Grammar - - YES - - - Show Spelling… - : - 1048576 - 2147483647 - - - - - - Check Spelling - ; - 1048576 - 2147483647 - - - - - - Check Spelling While Typing - - 1048576 - 2147483647 - - - - - - Check Grammar With Spelling - - 1048576 - 2147483647 - - - - - - - - - Substitutions - - 1048576 - 2147483647 - - - submenuAction: - - Substitutions - - YES - - - Smart Copy/Paste - f - 1048576 - 2147483647 - - - 1 - - - - Smart Quotes - g - 1048576 - 2147483647 - - - 2 - - - - Smart Links - G - 1179648 - 2147483647 - - - 3 - - - - - - - Speech - - 1048576 - 2147483647 - - - submenuAction: - - Speech - - YES - - - Start Speaking - - 1048576 - 2147483647 - - - - - - Stop Speaking - - 1048576 - 2147483647 - - - - - - - - - - - - Format - - 1048576 - 2147483647 - - - submenuAction: - - Format - - YES - - - Show Fonts - t - 1048576 - 2147483647 - - - - - - Show Colors - C - 1179648 - 2147483647 - - - - - - - - - View - - 1048576 - 2147483647 - - - submenuAction: - - View - - YES - - - Show Toolbar - t - 1572864 - 2147483647 - - - - - - Customize Toolbar… - - 1048576 - 2147483647 - - - - - - - - - Window - - 1048576 - 2147483647 - - - submenuAction: - - Window - - YES - - - Minimize - m - 1048576 - 2147483647 - - - - - - Zoom - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Bring All to Front - - 1048576 - 2147483647 - - - - - _NSWindowsMenu - - - - - Help - - 1048576 - 2147483647 - - - submenuAction: - - Help - - YES - - - NewApplication Help - ? - 1048576 - 2147483647 - - - - - - - - _NSMainMenu - - - 7 - 2 - {{335, 236}, {644, 514}} - 1946157056 - ASIHTTPRequest Examples - NSWindow - - - - - 256 - - YES - - - 1290 - - {{11, 16}, {151, 20}} - - - 16392 - 1 - - - - 12 - {{6, 35}, {625, 465}} - - - - - YES - - 1 - - - 256 - - YES - - - 268 - {{11, 301}, {62, 32}} - - - - YES - - 67239424 - 134217728 - Go! - - LucidaGrande - 13 - 1044 - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{14, 348}, {577, 64}} - - - - YES - - 67239424 - 272629760 - Demonstrates fetching a web page synchronously, the HTML source will appear in the box below when the download is complete. Because this synchronous download is running in the main thread, the interface will lock until the download is complete. - - - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - 3 - MAA - - - - - - - 282 - - YES - - - 2304 - - YES - - - 2322 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - public.url - - - {{0, 66}, {554, 14}} - - - - - - - - - - - - - YES - - - 6 - - - - 554 - 1 - - - 11239 - 0 - - - 3 - MQA - - - YES - - YES - NSBackgroundColor - NSColor - - - YES - - 6 - System - selectedTextBackgroundColor - - - - 6 - System - selectedTextColor - - - - - - - YES - - YES - NSColor - NSUnderline - - - YES - - 1 - MCAwIDEAA - - - - - - - 1 - - 6 - {807, 10000000} - {223, 0} - - - - {{1, 1}, {554, 281}} - - - - - - - {4, 5} - - 12582912 - - YES - - YES - - - - TU0AKgAAAHCAFUqgBVKsAAAAwdVQUqwaEQeIRGJRGFlYqwWLQ+JxuOQpVRmEx2RROKwOQyOUQSPyaUym -SxqWyKXyeYxyZzWbSuJTScRCbz2Nz+gRKhUOfTqeUai0OSxiWTiBQSHSGFquGwekxyAgAAAOAQAAAwAA -AAEAEAAAAQEAAwAAAAEAEAAAAQIAAwAAAAIACAAIAQMAAwAAAAEABQAAAQYAAwAAAAEAAQAAAREABAAA -AAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEAAgAAARYAAwAAAAEAEAAAARcABAAAAAEAAABnARwAAwAA -AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA - - - - - - 3 - MCAwAA - - - - 4 - - - - 256 - {{555, 1}, {15, 281}} - - - - - _doScroller: - 0.9512195 - - - - -2147483392 - {{-100, -100}, {87, 18}} - - - - 1 - - _doScroller: - 1 - 0.94565220000000005 - - - {{17, 17}, {571, 283}} - - - - 133138 - - - - - - {{10, 33}, {605, 419}} - - - - - Synchronous - - - - - 2 - - - 256 - - YES - - - 268 - {{11, 274}, {74, 32}} - - YES - - 67239424 - 134217728 - Start - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{85, 274}, {90, 32}} - - YES - - 604110336 - 134217728 - Resume - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{14, 320}, {577, 92}} - - YES - - 67239424 - 272629760 - RGVtb25zdHJhdGVzIGZldGNoaW5nIGEgbGFyZ2UgZmlsZSBkaXJlY3RseSB0byBkaXNrLCB1cGRhdGlu -ZyB0aGUgcHJvZ3Jlc3MgYmFyIGJlbG93IHRvIHNob3cgaG93IG11Y2ggaGFzIGJlZW4gZG93bmxvYWRl -ZC4KCklmIHRoZSByZXF1ZXN0IGlzIHN0b3BwZWQgcGFydCB3YXkgdGhyb3VnaCwgdXNlIHRoZSByZXN1 -bWUgYnV0dG9uIHRvIHBpY2sgdXAgd2hlcmUgd2UgbGVmdCBvZmYuA - - - - - - - - - 268 - {{14, 215}, {553, 40}} - - YES - - 67239424 - 272629760 - The path to the file will appear here once the download is complete - - - - - - - - {{10, 33}, {605, 419}} - - File - - - - - Item 2 - - - 256 - - YES - - - 268 - - YES - - YES - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - NSFilenamesPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT TIFF v4.0 pasteboard type - - - {{14, 169}, {190, 130}} - - YES - - 130560 - 33554432 - 0 - 0 - 2 - NO - - YES - - - - 268 - - YES - - YES - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - NSFilenamesPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT TIFF v4.0 pasteboard type - - - {{207, 169}, {190, 130}} - - YES - - 130560 - 33554432 - 0 - 0 - 2 - NO - - YES - - - - 268 - - YES - - YES - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - NSFilenamesPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT TIFF v4.0 pasteboard type - - - {{401, 169}, {190, 130}} - - YES - - 130560 - 33554432 - 0 - 0 - 2 - NO - - YES - - - - 268 - {{10, 306}, {62, 32}} - - YES - - 67239424 - 134217728 - Go! - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{14, 327}, {577, 85}} - - YES - - 67239424 - 272629760 - RGVtb25zdHJhdGVzIGEgZmV0Y2hpbmcgMyBpdGVtcyBhdCBvbmNlLCB1c2luZyBhbiBBU0lOZXR3b3Jr -UXVldWUgdG8gdHJhY2sgcHJvZ3Jlc3MuIEVhY2ggcmVxdWVzdCBoYXMgaXRzIGRvd25sb2FkUHJvZ3Jl -c3NEZWxlZ2F0ZSBzZXQgdG8gdGhlIHByb2dyZXNzIGluZGljYXRvciB1bmRlciB0aGUgaW1hZ2Ugdmll -dy4gVGhlIHF1ZXVlIG1hbmFnZXMgdGhlIG92ZXJhbGwgcHJvZ3Jlc3MgZGlzcGxheWVkIGF0IHRoZSBi -b3R0b20gb2YgdGhlIHdpbmRvdy4gCg - - - - - - - - - 268 - {{13, 17}, {577, 102}} - - YES - - 67239424 - 272629760 - V2hlbiBhY2N1cmF0ZSBwcm9ncmVzcyBpcyB0dXJuZWQgb2ZmLCBlYWNoIHJlcXVlc3Qgb25seSB1cGRh -dGVzIHByb2dyZXNzIHdoZW4gaXQgY29tcGxldGVzLiBUaGlzIG1lYW5zIHRoYXQgZWFjaCByZXF1ZXN0 -IGlzIHJlcHJlc2VudGVkIGJ5IHRoZSBzYW1lIGFtb3VudCBvZiBwcm9ncmVzcyBpbiB0aGUgcHJvZ3Jl -c3MgaW5kaWNhdG9yLgoKV2l0aCBhY2N1cmF0ZSBwcm9ncmVzcyB0dXJuZWQgb24sIHRoZSBxdWV1ZSB3 -aWxsIGZpcnN0IHBlcmZvcm0gYSBIRUFEIHJlcXVlc3QgZm9yIGVhY2ggaW1hZ2UgdG8gb2J0YWluIGl0 -cyBzaXplLiBSZXF1ZXN0cyB0aGVuIHVwZGF0ZSB0aGUgcHJvZ3Jlc3MgYXMgZGF0YSBpcyByZWNlaXZl -ZC4 - - - - - - - - - 268 - {{80, 315}, {172, 18}} - - YES - - 67239424 - 0 - Show accurate progress - - - 1211912703 - 2 - - NSImage - NSSwitch - - - NSSwitch - - - - 200 - 25 - - - - - 1292 - - {{16, 152}, {186, 12}} - - 16648 - 1 - - - - 1292 - - {{208, 152}, {187, 12}} - - 16648 - 1 - - - - 1292 - - {{403, 152}, {186, 12}} - - 16648 - 1 - - - - 268 - {{14, 129}, {190, 17}} - - YES - - 68288064 - 138413056 - This image is 15KB - - - - - - - - - 268 - {{206, 129}, {191, 17}} - - YES - - 68288064 - 138413056 - This image is 176KB - - - - - - - - - 268 - {{401, 129}, {185, 17}} - - YES - - 68288064 - 138413056 - This image is 1.4MB - - - - - - - - {{10, 33}, {605, 419}} - - Queue - - - - - Item 3 - - - 256 - - YES - - - 268 - {{14, 365}, {577, 47}} - - YES - - 67239424 - 272629760 - Demonstrates fetching content from an area that requires HTTP authentication. You will be prompted for a username and password, enter 'topsecret' for both. - - - - - - - - - 268 - {{11, 208}, {62, 32}} - - YES - - 67239424 - 134217728 - Go! - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{15, 341}, {160, 18}} - - YES - - 67239424 - 0 - Use the Keychain - - - 1211912703 - 2 - - - - - 200 - 25 - - - - - 268 - {{14, 253}, {577, 68}} - - YES - - 67239424 - 272629760 - If you turn on keychain support, successful authentication will result in the username and password you provided being stored in your keychain. The application will use these details rather than prompt you the next time. - - - - - - - - - 268 - {{14, 181}, {413, 17}} - - YES - - 67239488 - 272630784 - Top secret information will not appear here. - - - - - - - - {{10, 33}, {605, 419}} - - Authentication - - - - - Item 4 - - - 256 - - YES - - - 268 - {{14, 381}, {577, 31}} - - YES - - 67239424 - 272629760 - Demonstrates POSTing content to a URL, showing upload progress. - - - - - - - - - 268 - {{11, 345}, {62, 32}} - - YES - - 67239424 - 134217728 - Go! - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{14, 83}, {577, 256}} - - YES - - 67239424 - 272629760 - - - LucidaGrande - 13 - 16 - - - - - - - - {{10, 33}, {605, 419}} - - Upload - - - - - Item 5 - - - 256 - - YES - - - 268 - - YES - - - 2304 - - YES - - - 256 - {569, 269} - - YES - - - -2147483392 - {{224, 0}, {16, 17}} - - - YES - - image - 133 - 40 - 1000 - - 75628096 - 2048 - - - LucidaGrande - 11 - 3100 - - - 3 - MC4zMzMzMzI5ODU2AA - - - 6 - System - headerTextColor - - - - - 67239424 - 33554432 - - 0 - 0 - 0 - NO - - 3 - YES - YES - - - - 400 - 40 - 1000 - - 75628096 - 2048 - - - - - - - 67239424 - 4096 - Text Cell - - LucidaGrande - 11 - 16 - - - - 6 - System - controlBackgroundColor - - - - - 3 - YES - YES - - - - 3 - 2 - - 1 - MSAxIDEAA - - - 100 - 44040192 - - - 0 - 15 - 0 - NO - 0 - 1 - - - {{1, 1}, {569, 269}} - - - - - 4 - - - - -2147483392 - {{224, 17}, {15, 102}} - - - _doScroller: - 0.99591836734693873 - - - - -2147483392 - {{-100, -100}, {223, 15}} - - 1 - - _doScroller: - 0.57142859697341919 - - - {{17, 47}, {571, 271}} - - - 133650 - - - - QSAAAEEgAABCzAAAQswAAA - - - - 268 - {{14, 140}, {276, 17}} - - YES - - 68288064 - 272630784 - - - - - - - - - - 268 - {{434, 15}, {89, 25}} - - YES - - -2080244224 - 134217728 - Clear Cache - - - -2038152961 - 163 - - - 400 - 75 - - - - - 268 - {{531, 15}, {57, 25}} - - YES - - -2080244224 - 134217728 - Reload - - - -2038152961 - 163 - - - 400 - 75 - - - - - 268 - {{14, 326}, {577, 85}} - - YES - - 67239424 - 4194304 - The table view below is populated by downloading an XML file, then downloading the images from the URLs in the XML. The requests are configured to store their responses in the global ASIDownloadCache, and will re-use previously downloaded data if it exists rather than fetching it again. - - - - - - - - {{10, 33}, {605, 419}} - - Cache - - - - - Item 6 - - - 256 - - YES - - - 256 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple URL pasteboard type - Apple Web Archive pasteboard type - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - WebURLsWithTitlesPboardType - public.png - public.url - public.url-name - - - {{17, 85}, {571, 160}} - - - - - - - - YES - - YES - WebKitDefaultFixedFontSize - WebKitDefaultFontSize - WebKitMinimumFontSize - - - YES - - - - - - - YES - YES - - - - 268 - {{14, 344}, {577, 68}} - - - YES - - 67239424 - 4194304 - Demonstrates fetching a webpage with a single ASIWebPageRequest that downloads most external resources (images, stylesheets etc). These can be stored in a cache, or embeded directly in the HTML source. Once downloaded, a complete page may be cached indefinitely. - - - - - - - - - 268 - {{14, 315}, {480, 25}} - - - YES - - 67239424 - 4194304 - ASIWebPageRequest is an EXPERIMENTAL class, use at your own risk! - - LucidaGrande-Bold - 13 - 16 - - - - - - - - - 268 - {{536, 280}, {58, 32}} - - - YES - - 67239424 - 134217728 - Go - - - -2038284033 - 129 - - - 200 - 25 - - - - - 256 - - YES - - - 2304 - - YES - - - 2322 - {{0, -3}, {554, 14}} - - - - - - - HTML source will appear here - - - YES - - YES - NSFont - NSParagraphStyle - - - YES - - Monaco - 10 - 16 - - - 4 - - - - - - - - YES - - - 134 - - - - 554 - 1 - - - 12263 - 0 - - - - YES - - YES - NSBackgroundColor - NSColor - - - YES - - - - - - - YES - - YES - NSColor - NSCursor - NSUnderline - - - YES - - - {8, -8} - 13 - - - - - - - 1 - - 6 - {554, 10000000} - {223, 11} - - - - {{1, 1}, {554, 58}} - - - - - - 4 - - - - 256 - {{555, 1}, {15, 58}} - - - - _doScroller: - 1 - 0.85256409645080566 - - - - -2147483392 - {{-100, -100}, {87, 18}} - - - 1 - - _doScroller: - 1 - 0.94565218687057495 - - - {{17, 17}, {571, 60}} - - - 133138 - - - - - - - 268 - {{17, 286}, {517, 22}} - - - YES - - -1804468671 - 272630784 - http://allseeing-i.com/ASIHTTPRequest/tests/ASIWebPageRequest/index.html - - - YES - - 6 - System - textBackgroundColor - - - - 6 - System - textColor - - - - - - - 268 - {{15, 251}, {360, 18}} - - - YES - - -2080244224 - 0 - Embed external resources directly into HTML and CSS - - - 1211912703 - 2 - - - - - 200 - 25 - - - - - 268 - {{499, 251}, {89, 25}} - - - YES - - -2080244224 - 134217728 - Clear Cache - - - -2038152961 - 163 - - - 400 - 75 - - - - {{10, 33}, {605, 419}} - - - Web Page Fetch - - - - - - - 0 - YES - YES - - YES - - - - - - 268 - {{334, 20}, {293, 17}} - - - YES - - 68288064 - 71304192 - - - - - - - - - - 268 - {{171, 18}, {143, 18}} - - - YES - - 67239424 - 0 - Throttle bandwidth - - - 1211912703 - 2 - - - - - 200 - 25 - - - - {644, 514} - - - - {{0, 0}, {1440, 878}} - {10000000000000, 10000000000000} - YES - - - AppDelegate - - - 15 - 2 - {{196, 328}, {279, 182}} - 1677721600 - Window - NSWindow - - - - - 256 - - YES - - - 268 - {{17, 152}, {38, 17}} - - YES - - 67239488 - 272630784 - Host: - - - - - - - - - 268 - {{17, 120}, {47, 17}} - - YES - - 67239488 - 272630784 - Realm: - - - - - - - - - 268 - {{97, 152}, {165, 17}} - - YES - - 67239488 - 272630784 - host here - - - - - - - - - 268 - {{97, 120}, {165, 17}} - - YES - - 67239488 - 272630784 - realm here - - - - - - - - - 268 - {{17, 86}, {71, 17}} - - YES - - 67239488 - 272630784 - Username: - - - - - - - - - 268 - {{17, 53}, {71, 17}} - - YES - - 67239488 - 272630784 - Password: - - - - - - - - - 268 - {{100, 84}, {159, 22}} - - YES - - -1804468671 - 272630784 - - - - YES - - - - - - - 268 - {{100, 50}, {159, 22}} - - YES - - -1804468671 - 272630784 - - - - YES - - - - - - - 268 - {{14, 5}, {96, 32}} - - YES - - 67239424 - 134217728 - Cancel - - - -2038284033 - 129 - - Gw - 200 - 25 - - - - - 268 - {{169, 5}, {96, 32}} - - 1 - YES - - 67239424 - 134217728 - OK - - - -2038284033 - 129 - - DQ - 200 - 25 - - - - {279, 182} - - {{0, 0}, {1440, 878}} - {10000000000000, 10000000000000} - YES - - - - - YES - - - performMiniaturize: - - - - 37 - - - - arrangeInFront: - - - - 39 - - - - print: - - - - 86 - - - - runPageLayout: - - - - 87 - - - - clearRecentDocuments: - - - - 127 - - - - orderFrontStandardAboutPanel: - - - - 142 - - - - performClose: - - - - 193 - - - - toggleContinuousSpellChecking: - - - - 222 - - - - undo: - - - - 223 - - - - copy: - - - - 224 - - - - checkSpelling: - - - - 225 - - - - paste: - - - - 226 - - - - stopSpeaking: - - - - 227 - - - - cut: - - - - 228 - - - - showGuessPanel: - - - - 230 - - - - redo: - - - - 231 - - - - selectAll: - - - - 232 - - - - startSpeaking: - - - - 233 - - - - delete: - - - - 235 - - - - performZoom: - - - - 240 - - - - performFindPanelAction: - - - - 241 - - - - centerSelectionInVisibleArea: - - - - 245 - - - - toggleGrammarChecking: - - - - 347 - - - - toggleSmartInsertDelete: - - - - 355 - - - - toggleAutomaticQuoteSubstitution: - - - - 356 - - - - toggleAutomaticLinkDetection: - - - - 357 - - - - showHelp: - - - - 360 - - - - orderFrontColorPanel: - - - - 361 - - - - saveDocument: - - - - 362 - - - - saveDocumentAs: - - - - 363 - - - - revertDocumentToSaved: - - - - 364 - - - - runToolbarCustomizationPalette: - - - - 365 - - - - toggleToolbarShown: - - - - 366 - - - - hide: - - - - 367 - - - - hideOtherApplications: - - - - 368 - - - - terminate: - - - - 369 - - - - unhideAllApplications: - - - - 370 - - - - newDocument: - - - - 373 - - - - openDocument: - - - - 374 - - - - progressIndicator - - - - 385 - - - - loginWindow - - - - 414 - - - - window - - - - 415 - - - - host - - - - 416 - - - - realm - - - - 417 - - - - username - - - - 418 - - - - password - - - - 419 - - - - simpleURLFetch: - - - - 473 - - - - URLFetchWithProgress: - - - - 474 - - - - fetchThreeImages: - - - - 475 - - - - imageView1 - - - - 476 - - - - imageView2 - - - - 477 - - - - imageView3 - - - - 478 - - - - fileLocation - - - - 481 - - - - htmlSource - - - - 486 - - - - topSecretInfo - - - - 497 - - - - keychainCheckbox - - - - 498 - - - - fetchTopSecretInformation: - - - - 499 - - - - dismissAuthSheet: - - - - 500 - - - - dismissAuthSheet: - - - - 501 - - - - postWithProgress: - - - - 506 - - - - showAccurateProgress - - - - 515 - - - - resumeButton - - - - 522 - - - - startButton - - - - 523 - - - - resumeURLFetchWithProgress: - - - - 524 - - - - imageProgress1 - - - - 528 - - - - imageProgress2 - - - - 529 - - - - imageProgress3 - - - - 530 - - - - bandwidthUsed - - - - 537 - - - - throttleBandwidth: - - - - 542 - - - - postStatus - - - - 545 - - - - tableView - - - - 557 - - - - dataSource - - - - 558 - - - - delegate - - - - 559 - - - - delegate - - - - 560 - - - - tableLoadStatus - - - - 564 - - - - clearCache: - - - - 570 - - - - reloadTableData: - - - - 571 - - - - fetchWebPage: - - - - 589 - - - - webView - - - - 590 - - - - webPageSource - - - - 595 - - - - urlField - - - - 598 - - - - policyDelegate - - - - 600 - - - - dataURICheckbox - - - - 605 - - - - clearCache: - - - - 609 - - - - clearCache: - - - - 612 - - - - - YES - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 29 - - - YES - - - - - - - - - - MainMenu - - - 19 - - - YES - - - - - - 56 - - - YES - - - - - - 103 - - - YES - - - - 1 - - - 217 - - - YES - - - - - - 83 - - - YES - - - - - - 81 - - - YES - - - - - - - - - - - - - - - - 75 - - - 3 - - - 80 - - - 8 - - - 78 - - - 6 - - - 72 - - - - - 82 - - - 9 - - - 124 - - - YES - - - - - - 77 - - - 5 - - - 73 - - - 1 - - - 79 - - - 7 - - - 112 - - - 10 - - - 74 - - - 2 - - - 125 - - - YES - - - - - - 126 - - - - - 205 - - - YES - - - - - - - - - - - - - - - - - - 202 - - - - - 198 - - - - - 207 - - - - - 214 - - - - - 199 - - - - - 203 - - - - - 197 - - - - - 206 - - - - - 215 - - - - - 218 - - - YES - - - - - - 216 - - - YES - - - - - - 200 - - - YES - - - - - - - - - 219 - - - - - 201 - - - - - 204 - - - - - 220 - - - YES - - - - - - - - - - 213 - - - - - 210 - - - - - 221 - - - - - 208 - - - - - 209 - - - - - 106 - - - YES - - - - 2 - - - 111 - - - - - 57 - - - YES - - - - - - - - - - - - - - - - 58 - - - - - 134 - - - - - 150 - - - - - 136 - - - 1111 - - - 144 - - - - - 129 - - - 121 - - - 143 - - - - - 236 - - - - - 131 - - - YES - - - - - - 149 - - - - - 145 - - - - - 130 - - - - - 24 - - - YES - - - - - - - - - 92 - - - - - 5 - - - - - 239 - - - - - 23 - - - - - 295 - - - YES - - - - - - 296 - - - YES - - - - - - - 297 - - - - - 298 - - - - - 299 - - - YES - - - - - - 300 - - - YES - - - - - - - 344 - - - - - 345 - - - - - 211 - - - YES - - - - - - 212 - - - YES - - - - - - - 195 - - - - - 196 - - - - - 346 - - - - - 348 - - - YES - - - - - - 349 - - - YES - - - - - - - - 350 - - - - - 351 - - - - - 354 - - - - - 371 - - - YES - - - - - - 372 - - - YES - - - - - - - - - 381 - - - - - 384 - - - - - 390 - - - YES - - - - - - 391 - - - YES - - - - - - - - - - - - - - - 392 - - - YES - - - - - - 393 - - - - - 394 - - - YES - - - - - - 395 - - - - - 398 - - - YES - - - - - - 399 - - - - - 400 - - - YES - - - - - - 401 - - - - - 402 - - - YES - - - - - - 403 - - - - - 404 - - - YES - - - - - - 405 - - - - - 406 - - - YES - - - - - - 407 - - - - - 408 - - - YES - - - - - - 409 - - - - - 410 - - - YES - - - - - - 411 - - - - - 412 - - - YES - - - - - - 413 - - - - - 434 - - - YES - - - - - - - - - - - - 436 - - - YES - - - - - - 437 - - - YES - - - - - - - - - 439 - - - YES - - - - - - 440 - - - YES - - - - - - - - - - - - - - - - - - 441 - - - YES - - - - - - 442 - - - YES - - - - - - - - - - 443 - - - YES - - - - - - 444 - - - YES - - - - - - - - 451 - - - YES - - - - - - 452 - - - YES - - - - - - 453 - - - YES - - - - - - 454 - - - - - 455 - - - - - 456 - - - - - 459 - - - YES - - - - - - 460 - - - - - 461 - - - YES - - - - - - 462 - - - - - 467 - - - YES - - - - - - 468 - - - - - 469 - - - YES - - - - - - 470 - - - - - 479 - - - YES - - - - - - 480 - - - - - 435 - - - YES - - - - - - 438 - - - YES - - - - - - - - 471 - - - YES - - - - - - 472 - - - - - 457 - - - YES - - - - - - 458 - - - - - 482 - - - YES - - - - - - - - 483 - - - - - 484 - - - - - 485 - - - - - 487 - - - YES - - - - - - 488 - - - YES - - - - - - 489 - - - - - 490 - - - - - 491 - - - YES - - - - - - 492 - - - - - 493 - - - YES - - - - - - 494 - - - - - 495 - - - YES - - - - - - 496 - - - - - 502 - - - YES - - - - - - 503 - - - - - 504 - - - YES - - - - - - 505 - - - - - 513 - - - YES - - - - - - 514 - - - - - 520 - - - YES - - - - - - 521 - - - - - 525 - - - - - 526 - - - - - 527 - - - - - 535 - - - YES - - - - - - 536 - - - - - 540 - - - YES - - - - - - 541 - - - - - 543 - - - YES - - - - - - 544 - - - - - 546 - - - YES - - - - - - 547 - - - YES - - - - - - - - - - 548 - - - YES - - - - - - - - 549 - - - - - 550 - - - - - 551 - - - YES - - - - - - - 553 - - - YES - - - - - - 554 - - - YES - - - - - - 555 - - - - - 561 - - - - - 562 - - - YES - - - - - - 563 - - - - - 566 - - - YES - - - - - - 567 - - - - - 568 - - - YES - - - - - - 569 - - - - - 572 - - - YES - - - - - - 573 - - - - - 574 - - - YES - - - - - - 575 - - - YES - - - - - - - - - - - - - 576 - - - YES - - - - - - 577 - - - - - 578 - - - YES - - - - - - 579 - - - - - 580 - - - YES - - - - - - 581 - - - - - 582 - - - - - 583 - - - YES - - - - - - 584 - - - - - 585 - - - YES - - - - - - 586 - - - - - 587 - - - YES - - - - - - 588 - - - - - 591 - - - YES - - - - - - - - 592 - - - - - 593 - - - - - 594 - - - - - 596 - - - YES - - - - - - 597 - - - - - 603 - - - YES - - - - - - 604 - - - - - 606 - - - YES - - - - - - 607 - - - - - 610 - - - YES - - - - - - 611 - - - - - - - YES - - YES - -1.IBPluginDependency - -2.IBPluginDependency - -3.IBPluginDependency - 103.IBPluginDependency - 106.IBPluginDependency - 111.IBPluginDependency - 112.IBPluginDependency - 124.IBPluginDependency - 125.IBPluginDependency - 126.IBPluginDependency - 129.IBPluginDependency - 130.IBPluginDependency - 131.IBPluginDependency - 134.IBPluginDependency - 136.IBPluginDependency - 143.IBPluginDependency - 144.IBPluginDependency - 145.IBPluginDependency - 149.IBPluginDependency - 150.IBPluginDependency - 19.IBPluginDependency - 195.IBPluginDependency - 196.IBPluginDependency - 197.IBPluginDependency - 198.IBPluginDependency - 199.IBPluginDependency - 200.IBPluginDependency - 201.IBPluginDependency - 202.IBPluginDependency - 203.IBPluginDependency - 204.IBPluginDependency - 205.IBPluginDependency - 206.IBPluginDependency - 207.IBPluginDependency - 208.IBPluginDependency - 209.IBPluginDependency - 210.IBPluginDependency - 211.IBPluginDependency - 212.IBPluginDependency - 213.IBPluginDependency - 214.IBPluginDependency - 215.IBPluginDependency - 216.IBPluginDependency - 217.IBPluginDependency - 218.IBPluginDependency - 219.IBPluginDependency - 220.IBPluginDependency - 221.IBPluginDependency - 23.IBPluginDependency - 236.IBPluginDependency - 239.IBPluginDependency - 24.IBPluginDependency - 29.IBPluginDependency - 295.IBPluginDependency - 296.IBPluginDependency - 297.IBPluginDependency - 298.IBPluginDependency - 299.IBPluginDependency - 300.IBPluginDependency - 344.IBPluginDependency - 345.IBPluginDependency - 346.IBPluginDependency - 348.IBPluginDependency - 349.IBPluginDependency - 350.IBPluginDependency - 351.IBPluginDependency - 354.IBPluginDependency - 371.IBPluginDependency - 371.IBWindowTemplateEditedContentRect - 371.NSWindowTemplate.visibleAtLaunch - 372.IBPluginDependency - 381.IBPluginDependency - 384.IBPluginDependency - 390.IBPluginDependency - 390.IBWindowTemplateEditedContentRect - 390.NSWindowTemplate.visibleAtLaunch - 391.IBPluginDependency - 392.IBPluginDependency - 393.IBPluginDependency - 394.IBPluginDependency - 395.IBPluginDependency - 398.IBPluginDependency - 399.IBPluginDependency - 400.IBPluginDependency - 401.IBPluginDependency - 402.IBPluginDependency - 403.IBPluginDependency - 404.IBPluginDependency - 405.IBPluginDependency - 406.IBPluginDependency - 407.IBPluginDependency - 408.IBPluginDependency - 409.IBPluginDependency - 410.IBPluginDependency - 411.IBPluginDependency - 412.IBPluginDependency - 413.IBPluginDependency - 434.IBPluginDependency - 435.IBPluginDependency - 436.IBPluginDependency - 437.IBPluginDependency - 438.IBPluginDependency - 439.IBPluginDependency - 440.IBPluginDependency - 441.IBPluginDependency - 442.IBPluginDependency - 443.IBPluginDependency - 444.IBPluginDependency - 451.IBPluginDependency - 452.IBPluginDependency - 453.IBPluginDependency - 454.IBPluginDependency - 455.IBPluginDependency - 456.IBPluginDependency - 457.IBPluginDependency - 458.IBPluginDependency - 459.IBPluginDependency - 460.IBPluginDependency - 461.IBPluginDependency - 462.IBPluginDependency - 467.IBPluginDependency - 468.IBPluginDependency - 469.IBPluginDependency - 470.IBPluginDependency - 471.IBPluginDependency - 472.IBPluginDependency - 479.IBPluginDependency - 480.IBPluginDependency - 482.IBPluginDependency - 483.IBPluginDependency - 484.IBPluginDependency - 485.IBPluginDependency - 487.IBPluginDependency - 488.IBPluginDependency - 489.IBPluginDependency - 490.IBPluginDependency - 491.IBPluginDependency - 492.IBPluginDependency - 493.IBPluginDependency - 494.IBPluginDependency - 495.IBPluginDependency - 496.IBPluginDependency - 5.IBPluginDependency - 502.IBPluginDependency - 503.IBPluginDependency - 504.IBPluginDependency - 505.IBPluginDependency - 513.IBPluginDependency - 514.IBPluginDependency - 520.IBPluginDependency - 521.IBPluginDependency - 525.IBPluginDependency - 526.IBPluginDependency - 527.IBPluginDependency - 535.IBPluginDependency - 536.IBPluginDependency - 540.IBPluginDependency - 541.IBPluginDependency - 543.IBPluginDependency - 544.IBPluginDependency - 546.IBPluginDependency - 547.IBPluginDependency - 548.IBPluginDependency - 549.IBPluginDependency - 550.IBPluginDependency - 551.IBPluginDependency - 553.IBPluginDependency - 554.IBPluginDependency - 555.IBPluginDependency - 56.IBPluginDependency - 561.IBPluginDependency - 562.IBPluginDependency - 563.IBPluginDependency - 566.IBPluginDependency - 567.IBPluginDependency - 568.IBPluginDependency - 569.IBPluginDependency - 57.IBPluginDependency - 572.IBPluginDependency - 573.IBPluginDependency - 574.IBPluginDependency - 575.IBPluginDependency - 576.IBPluginDependency - 577.IBPluginDependency - 578.IBPluginDependency - 579.IBPluginDependency - 58.IBPluginDependency - 580.IBPluginDependency - 581.IBPluginDependency - 582.IBPluginDependency - 583.IBPluginDependency - 584.IBPluginDependency - 585.IBPluginDependency - 586.IBPluginDependency - 587.IBPluginDependency - 588.IBPluginDependency - 591.IBPluginDependency - 592.IBPluginDependency - 593.IBPluginDependency - 594.IBPluginDependency - 596.IBPluginDependency - 597.IBPluginDependency - 603.IBPluginDependency - 604.IBPluginDependency - 606.IBPluginDependency - 607.IBPluginDependency - 610.IBPluginDependency - 611.IBPluginDependency - 72.IBPluginDependency - 73.IBPluginDependency - 74.IBPluginDependency - 75.IBPluginDependency - 77.IBPluginDependency - 78.IBPluginDependency - 79.IBPluginDependency - 80.IBPluginDependency - 81.IBPluginDependency - 82.IBPluginDependency - 83.IBPluginDependency - 92.IBPluginDependency - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{468, 239}, {644, 514}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{329, 629}, {279, 182}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - YES - - - - - - YES - - - - - 612 - - - - YES - - AppDelegate - NSObject - - YES - - YES - URLFetchWithProgress: - clearCache: - dismissAuthSheet: - fetchThreeImages: - fetchTopSecretInformation: - fetchWebPage: - postWithProgress: - reloadTableData: - resumeURLFetchWithProgress: - simpleURLFetch: - stopURLFetchWithProgress: - throttleBandwidth: - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - URLFetchWithProgress: - clearCache: - dismissAuthSheet: - fetchThreeImages: - fetchTopSecretInformation: - fetchWebPage: - postWithProgress: - reloadTableData: - resumeURLFetchWithProgress: - simpleURLFetch: - stopURLFetchWithProgress: - throttleBandwidth: - - - YES - - URLFetchWithProgress: - id - - - clearCache: - id - - - dismissAuthSheet: - id - - - fetchThreeImages: - id - - - fetchTopSecretInformation: - id - - - fetchWebPage: - id - - - postWithProgress: - id - - - reloadTableData: - id - - - resumeURLFetchWithProgress: - id - - - simpleURLFetch: - id - - - stopURLFetchWithProgress: - id - - - throttleBandwidth: - id - - - - - YES - - YES - bandwidthUsed - dataURICheckbox - fileLocation - host - htmlSource - imageProgress1 - imageProgress2 - imageProgress3 - imageView1 - imageView2 - imageView3 - keychainCheckbox - loginWindow - password - postStatus - progressIndicator - realm - resumeButton - showAccurateProgress - startButton - tableLoadStatus - tableView - topSecretInfo - urlField - username - webPageSource - webView - window - - - YES - NSTextField - NSButton - NSTextField - NSTextField - NSTextView - NSProgressIndicator - NSProgressIndicator - NSProgressIndicator - NSImageView - NSImageView - NSImageView - NSButton - NSWindow - NSTextField - NSTextField - NSProgressIndicator - NSTextField - NSButton - NSButton - NSButton - NSTextField - NSTableView - NSTextField - NSTextField - NSTextField - NSTextView - WebView - NSWindow - - - - YES - - YES - bandwidthUsed - dataURICheckbox - fileLocation - host - htmlSource - imageProgress1 - imageProgress2 - imageProgress3 - imageView1 - imageView2 - imageView3 - keychainCheckbox - loginWindow - password - postStatus - progressIndicator - realm - resumeButton - showAccurateProgress - startButton - tableLoadStatus - tableView - topSecretInfo - urlField - username - webPageSource - webView - window - - - YES - - bandwidthUsed - NSTextField - - - dataURICheckbox - NSButton - - - fileLocation - NSTextField - - - host - NSTextField - - - htmlSource - NSTextView - - - imageProgress1 - NSProgressIndicator - - - imageProgress2 - NSProgressIndicator - - - imageProgress3 - NSProgressIndicator - - - imageView1 - NSImageView - - - imageView2 - NSImageView - - - imageView3 - NSImageView - - - keychainCheckbox - NSButton - - - loginWindow - NSWindow - - - password - NSTextField - - - postStatus - NSTextField - - - progressIndicator - NSProgressIndicator - - - realm - NSTextField - - - resumeButton - NSButton - - - showAccurateProgress - NSButton - - - startButton - NSButton - - - tableLoadStatus - NSTextField - - - tableView - NSTableView - - - topSecretInfo - NSTextField - - - urlField - NSTextField - - - username - NSTextField - - - webPageSource - NSTextView - - - webView - WebView - - - window - NSWindow - - - - - IBProjectSource - ./Classes/AppDelegate.h - - - - BWSplitView - NSSplitView - - toggleCollapse: - id - - - toggleCollapse: - - toggleCollapse: - id - - - - IBProjectSource - ./Classes/BWSplitView.h - - - - GHTestViewController - NSViewController - - YES - - YES - copy: - openExceptionFilename: - rerunTest: - runTests: - toggleDetails: - updateMode: - updateSearchFilter: - updateTextSegment: - - - YES - id - id - id - id - id - id - id - id - - - - YES - - YES - copy: - openExceptionFilename: - rerunTest: - runTests: - toggleDetails: - updateMode: - updateSearchFilter: - updateTextSegment: - - - YES - - copy: - id - - - openExceptionFilename: - id - - - rerunTest: - id - - - runTests: - id - - - toggleDetails: - id - - - updateMode: - id - - - updateSearchFilter: - id - - - updateTextSegment: - id - - - - - YES - - YES - _detailsView - _outlineView - _searchField - _segmentedControl - _splitView - _statusView - _textSegmentedControl - _textView - - - YES - NSView - NSOutlineView - NSSearchField - NSSegmentedControl - BWSplitView - NSView - NSSegmentedControl - NSTextView - - - - YES - - YES - _detailsView - _outlineView - _searchField - _segmentedControl - _splitView - _statusView - _textSegmentedControl - _textView - - - YES - - _detailsView - NSView - - - _outlineView - NSOutlineView - - - _searchField - NSSearchField - - - _segmentedControl - NSSegmentedControl - - - _splitView - BWSplitView - - - _statusView - NSView - - - _textSegmentedControl - NSSegmentedControl - - - _textView - NSTextView - - - - - IBProjectSource - ./Classes/GHTestViewController.h - - - - GHTestWindowController - NSWindowController - - YES - - YES - copy: - runTests: - - - YES - id - id - - - - YES - - YES - copy: - runTests: - - - YES - - copy: - id - - - runTests: - id - - - - - viewController - GHTestViewController - - - viewController - - viewController - GHTestViewController - - - - IBProjectSource - ./Classes/GHTestWindowController.h - - - - NSDocument - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - id - id - id - id - id - id - - - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - - IBProjectSource - ./Classes/NSDocument.h - - - - WebView - - reloadFromOrigin: - id - - - reloadFromOrigin: - - reloadFromOrigin: - id - - - - IBProjectSource - ./Classes/WebView.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - 3 - - YES - - YES - NSMenuCheckmark - NSMenuMixedState - NSSwitch - - - YES - {9, 8} - {7, 2} - {15, 15} - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Demonstrates fetching a web page synchronously, the HTML source will appear in the box below when the download is complete. Because this synchronous download is running in the main thread, the interface will lock until the download is complete. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Demonstrates fetching a large file directly to disk, updating the progress bar below to show how much has been downloaded. + +If the request is stopped part way through, use the resume button to pick up where we left off. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Demonstrates a fetching 3 items at once, using an ASINetworkQueue to track progress. Each request has its downloadProgressDelegate set to the progress indicator under the image view. The queue manages the overall progress displayed at the bottom of the window. + + + + + + + + + + + When accurate progress is turned off, each request only updates progress when it completes. This means that each request is represented by the same amount of progress in the progress indicator. + +With accurate progress turned on, the queue will first perform a HEAD request for each image to obtain its size. Requests then update the progress as data is received. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Demonstrates fetching content from an area that requires HTTP authentication. You will be prompted for a username and password, enter 'topsecret' for both. + + + + + + + + + + + + If you turn on keychain support, successful authentication will result in the username and password you provided being stored in your keychain. The application will use these details rather than prompt you the next time. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The table view below is populated by downloading an XML file, then downloading the images from the URLs in the XML. The requests are configured to store their responses in the global ASIDownloadCache, and will re-use previously downloaded data if it exists rather than fetching it again. + + + + + + + + + + + + + + + + + + + + + + + + + + Demonstrates fetching a webpage with a single ASIWebPageRequest that downloads most external resources (images, stylesheets etc). These can be stored in a cache, or embeded directly in the HTML source. Once downloaded, a complete page may be cached indefinitely. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mac Sample/Info.plist b/Mac Sample/Info.plist index b02ccc55..d1331475 100644 --- a/Mac Sample/Info.plist +++ b/Mac Sample/Info.plist @@ -4,12 +4,14 @@ CFBundleDevelopmentRegion English + CFBundleDisplayName + ASIHTTPRequest Demo CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile CFBundleIdentifier - com.allseeing-i.asi-http-request + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,7 +26,5 @@ MainMenu NSPrincipalClass NSApplication - CFBundleDisplayName - ASIHTTPRequest Demo diff --git a/Mac Sample/Tests-Info.plist b/Mac Sample/Tests-Info.plist index 6d20d05b..b4e1a444 100644 --- a/Mac Sample/Tests-Info.plist +++ b/Mac Sample/Tests-Info.plist @@ -4,12 +4,14 @@ CFBundleDevelopmentRegion English + CFBundleDisplayName + ASIHTTPRequest Unit Tests CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile CFBundleIdentifier - com.allseeing-i.asi-http-request + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,7 +26,5 @@ MainMenu NSPrincipalClass NSApplication - CFBundleDisplayName - ASIHTTPRequest Unit Tests diff --git a/Mac.xcodeproj/project.pbxproj b/Mac.xcodeproj/project.pbxproj index d6fa1b47..a89a2469 100644 --- a/Mac.xcodeproj/project.pbxproj +++ b/Mac.xcodeproj/project.pbxproj @@ -62,7 +62,7 @@ B5B513860FBEE515002C74D0 /* GHUnitTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B513850FBEE515002C74D0 /* GHUnitTestMain.m */; }; B5BF64E612FDE9CA00CBC324 /* GHUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5BF64E512FDE9C900CBC324 /* GHUnit.framework */; }; B5C664BC100A6220004F3C96 /* ASIS3RequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C664BB100A6220004F3C96 /* ASIS3RequestTests.m */; }; - B5ED5A9412FEBAEC00A12511 /* GHUnit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B5BF64E512FDE9C900CBC324 /* GHUnit.framework */; }; + B5ED5A9412FEBAEC00A12511 /* GHUnit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B5BF64E512FDE9C900CBC324 /* GHUnit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -443,7 +443,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0910; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Mac" */; compatibilityVersion = "Xcode 3.2"; @@ -599,7 +599,6 @@ baseConfigurationReference = B515507810BD56E800608267 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/External/GHUnit\""; GCC_C_LANGUAGE_STANDARD = "compiler-default"; @@ -614,13 +613,13 @@ INFOPLIST_FILE = "Mac Sample/Tests-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ( "-framework", Foundation, "-framework", AppKit, ); + PRODUCT_BUNDLE_IDENTIFIER = "com.allseeing-i.asi-http-request"; PRODUCT_NAME = "Unit Tests (GHUnit)"; SDKROOT = macosx; }; @@ -631,7 +630,6 @@ baseConfigurationReference = B515507810BD56E800608267 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/External/GHUnit\""; @@ -643,13 +641,13 @@ HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "Mac Sample/Tests-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; - MACOSX_DEPLOYMENT_TARGET = 10.5; OTHER_LDFLAGS = ( "-framework", Foundation, "-framework", AppKit, ); + PRODUCT_BUNDLE_IDENTIFIER = "com.allseeing-i.asi-http-request"; PRODUCT_NAME = "Unit Tests (GHUnit)"; SDKROOT = macosx; ZERO_LINK = NO; @@ -661,7 +659,6 @@ baseConfigurationReference = B515507810BD56E800608267 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; COPY_PHASE_STRIP = NO; @@ -673,10 +670,11 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Mac Sample/Mac_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ""; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "Mac Sample/Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; - MACOSX_DEPLOYMENT_TARGET = 10.5; + PRODUCT_BUNDLE_IDENTIFIER = "com.allseeing-i.asi-http-request"; PRODUCT_NAME = Mac; SDKROOT = macosx; }; @@ -687,7 +685,6 @@ baseConfigurationReference = B515507810BD56E800608267 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -696,10 +693,11 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Mac Sample/Mac_Prefix.pch"; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "Mac Sample/Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; - MACOSX_DEPLOYMENT_TARGET = 10.5; + PRODUCT_BUNDLE_IDENTIFIER = "com.allseeing-i.asi-http-request"; PRODUCT_NAME = Mac; SDKROOT = macosx; }; @@ -708,10 +706,32 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = "compiler-default"; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; @@ -722,9 +742,30 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = "compiler-default"; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.6; SDKROOT = macosx; diff --git a/README.textile b/README.textile index 7fe1f908..d4d8389f 100644 --- a/README.textile +++ b/README.textile @@ -1,3 +1,12 @@ + +*Updated Fork for the discontinued ASIHTTPRequest project* + +Use it by adding `pod 'ASIHTTPRequest', :git => 'https://github.com/codelathe/asi-http-request.git'` to their Podfile. + +Pull request to the original repository https://github.com/pokeb/asi-http-request/pull/412. + +--- + ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications. It is suitable performing basic HTTP requests and interacting with REST-based services (GET / POST / PUT / DELETE). The included ASIFormDataRequest subclass makes it easy to submit POST data and files using multipart/form-data. @@ -27,6 +36,6 @@ It provides: * Get notifications about changes in your request state via delegation or [NEW] blocks (Mac OS X 10.6, iOS 4 and above) * Comes with a broad range of unit tests -ASIHTTPRequest is compatible with Mac OS 10.5 or later, and iOS 3.0 or later. +ASIHTTPRequest is compatible with Mac OS 10.6 or later, and iOS 8.0 or later. -Documentation is available "here":http://allseeing-i.com/ASIHTTPRequest. \ No newline at end of file +Documentation is available "here":http://allseeing-i.com/ASIHTTPRequest. diff --git a/iPhone Sample/AuthenticationViewController.m b/iPhone Sample/AuthenticationViewController.m index c6a8e3ef..53e4e2cb 100644 --- a/iPhone Sample/AuthenticationViewController.m +++ b/iPhone Sample/AuthenticationViewController.m @@ -51,7 +51,7 @@ - (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)theRequest - (void)authenticationNeededForRequest:(ASIHTTPRequest *)theRequest { - UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Please Login" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil] autorelease]; + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please Login" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil]; // These are undocumented, use at your own risk! // A better general approach would be to subclass UIAlertView, or just use ASIHTTPRequest's built-in dialog [alertView addTextFieldWithValue:@"" label:@"Username"]; @@ -62,7 +62,7 @@ - (void)authenticationNeededForRequest:(ASIHTTPRequest *)theRequest - (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)theRequest { - UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Please Login to proxy" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil] autorelease]; + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please Login to proxy" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil]; [alertView addTextFieldWithValue:@"" label:@"Username"]; [alertView addTextFieldWithValue:@"" label:@"Password"]; [alertView show]; @@ -107,9 +107,6 @@ - (void)didReceiveMemoryWarning { - (void)dealloc { [request cancel]; - [request release]; - [responseField release]; - [super dealloc]; } /* @@ -137,7 +134,7 @@ - (UIView *)tableView:(UITableView *)theTableView viewForHeaderInSection:(NSInte tablePadding = 110; } - UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)] autorelease]; + UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)]; UIButton *goButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [goButton setTitle:@"Go!" forState:UIControlStateNormal]; [goButton sizeToFit]; @@ -187,7 +184,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath cell = [tableView dequeueReusableCellWithIdentifier:@"Response"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"]; [[cell contentView] addSubview:responseField]; diff --git a/iPhone Sample/DetailCell.m b/iPhone Sample/DetailCell.m index c1c1e8e7..c72ac08e 100644 --- a/iPhone Sample/DetailCell.m +++ b/iPhone Sample/DetailCell.m @@ -13,8 +13,8 @@ @implementation DetailCell + (id)cell { - DetailCell *cell = [[[DetailCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"HeaderCell"] autorelease]; - [[cell detailTextLabel] setTextAlignment:UITextAlignmentLeft]; + DetailCell *cell = [[DetailCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"HeaderCell"]; + [[cell detailTextLabel] setTextAlignment:NSTextAlignmentLeft]; [[cell detailTextLabel] setFont:[UIFont systemFontOfSize:14]]; return cell; } diff --git a/iPhone Sample/GHUnitIOSTestMain.m b/iPhone Sample/GHUnitIOSTestMain.m index 08bf2ed3..10bfed7a 100644 --- a/iPhone Sample/GHUnitIOSTestMain.m +++ b/iPhone Sample/GHUnitIOSTestMain.m @@ -36,7 +36,7 @@ // Default exception handler void exceptionHandler(NSException *exception) { - NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception)); +// NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception)); } int main(int argc, char *argv[]) { @@ -79,4 +79,4 @@ int main(int argc, char *argv[]) { } [pool release]; return retVal; -} \ No newline at end of file +} diff --git a/iPhone Sample/InfoCell.m b/iPhone Sample/InfoCell.m index 31f95f9d..f73b2fb4 100644 --- a/iPhone Sample/InfoCell.m +++ b/iPhone Sample/InfoCell.m @@ -13,17 +13,17 @@ @implementation InfoCell + (id)cell { - InfoCell *cell = [[[InfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InfoCell"] autorelease]; + InfoCell *cell = [[InfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"InfoCell"]; if ([[UIScreen mainScreen] bounds].size.width > 480) { // iPad [[cell textLabel] setFont:[UIFont systemFontOfSize:14]]; } else { [[cell textLabel] setFont:[UIFont systemFontOfSize:13]]; } - [[cell textLabel] setLineBreakMode:UILineBreakModeWordWrap]; + [[cell textLabel] setLineBreakMode:NSLineBreakByWordWrapping]; [[cell textLabel] setNumberOfLines:0]; if ([[UIScreen mainScreen] bounds].size.width > 480) { // iPad - UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(10,10,48,48)] autorelease]; + UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10,10,48,48)]; [imageView setImage:[UIImage imageNamed:@"info.png"]]; [[cell contentView] addSubview:imageView]; } @@ -33,8 +33,8 @@ + (id)cell - (void)layoutSubviews { [super layoutSubviews]; - int tablePadding = 40; - int tableWidth = [[self superview] frame].size.width; + NSUInteger tablePadding = 40; + NSUInteger tableWidth = [[self superview] frame].size.width; if (tableWidth > 480) { // iPad tablePadding = 110; [[self textLabel] setFrame:CGRectMake(70,10,tableWidth-tablePadding-70,[[self class] neededHeightForDescription:[[self textLabel] text] withTableWidth:tableWidth])]; @@ -46,15 +46,15 @@ - (void)layoutSubviews + (NSUInteger)neededHeightForDescription:(NSString *)description withTableWidth:(NSUInteger)tableWidth { - int tablePadding = 40; - int offset = 0; + NSUInteger tablePadding = 40; + NSUInteger offset = 0; int textSize = 13; if (tableWidth > 480) { // iPad tablePadding = 110; offset = 70; textSize = 14; } - CGSize labelSize = [description sizeWithFont:[UIFont systemFontOfSize:textSize] constrainedToSize:CGSizeMake(tableWidth-tablePadding-offset,1000) lineBreakMode:UILineBreakModeWordWrap]; + CGSize labelSize = [description sizeWithFont:[UIFont systemFontOfSize:textSize] constrainedToSize:CGSizeMake(tableWidth-tablePadding-offset,1000) lineBreakMode:NSLineBreakByWordWrapping]; if (labelSize.height < 48) { return 58; } diff --git a/iPhone Sample/QueueViewController.m b/iPhone Sample/QueueViewController.m index 27d5f8a5..8707080f 100644 --- a/iPhone Sample/QueueViewController.m +++ b/iPhone Sample/QueueViewController.m @@ -44,13 +44,13 @@ - (IBAction)fetchThreeImages:(id)sender [request setUserInfo:[NSDictionary dictionaryWithObject:@"request1" forKey:@"name"]]; [networkQueue addOperation:request]; - request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/medium-image.jpg"]] autorelease]; + request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/medium-image.jpg"]]; [request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"2.png"]]; [request setDownloadProgressDelegate:imageProgressIndicator2]; [request setUserInfo:[NSDictionary dictionaryWithObject:@"request2" forKey:@"name"]]; [networkQueue addOperation:request]; - request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/large-image.jpg"]] autorelease]; + request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/large-image.jpg"]]; [request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"3.png"]]; [request setDownloadProgressDelegate:imageProgressIndicator3]; [request setUserInfo:[NSDictionary dictionaryWithObject:@"request3" forKey:@"name"]]; @@ -80,7 +80,7 @@ - (void)imageFetchFailed:(ASIHTTPRequest *)request { if (!failed) { if ([[request error] domain] != NetworkRequestErrorDomain || [[request error] code] != ASIRequestCancelledErrorType) { - UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Download failed" message:@"Failed to download images" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Download failed" message:@"Failed to download images" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } failed = YES; @@ -88,10 +88,7 @@ - (void)imageFetchFailed:(ASIHTTPRequest *)request } - (void)dealloc { - [progressIndicator release]; [networkQueue reset]; - [networkQueue release]; - [super dealloc]; } @@ -116,7 +113,7 @@ - (UIView *)tableView:(UITableView *)theTableView viewForHeaderInSection:(NSInte tablePadding = 110; } - UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)] autorelease]; + UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)]; UIButton *goButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [goButton setTitle:@"Go!" forState:UIControlStateNormal]; [goButton sizeToFit]; @@ -169,58 +166,58 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ImagesCell"] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ImagesCell"]; - imageView1 = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease]; + imageView1 = [[UIImageView alloc] initWithFrame:CGRectZero]; [imageView1 setBackgroundColor:[UIColor grayColor]]; [cell addSubview:imageView1]; - imageProgressIndicator1 = [[[UIProgressView alloc] initWithFrame:CGRectZero] autorelease]; + imageProgressIndicator1 = [[UIProgressView alloc] initWithFrame:CGRectZero]; [cell addSubview:imageProgressIndicator1]; - imageLabel1 = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; + imageLabel1 = [[UILabel alloc] initWithFrame:CGRectZero]; if (tableWidth > 480) { [imageLabel1 setText:@"This image is 15KB in size"]; } else { [imageLabel1 setText:@"Img size: 15KB"]; } - [imageLabel1 setTextAlignment:UITextAlignmentCenter]; + [imageLabel1 setTextAlignment:NSTextAlignmentCenter]; [imageLabel1 setFont:[UIFont systemFontOfSize:11]]; [imageLabel1 setBackgroundColor:[UIColor clearColor]]; [cell addSubview:imageLabel1]; - imageView2 = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease]; + imageView2 = [[UIImageView alloc] initWithFrame:CGRectZero]; [imageView2 setBackgroundColor:[UIColor grayColor]]; [cell addSubview:imageView2]; - imageProgressIndicator2 = [[[UIProgressView alloc] initWithFrame:CGRectZero] autorelease]; + imageProgressIndicator2 = [[UIProgressView alloc] initWithFrame:CGRectZero]; [cell addSubview:imageProgressIndicator2]; - imageLabel2 = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; + imageLabel2 = [[UILabel alloc] initWithFrame:CGRectZero]; if (tableWidth > 480) { [imageLabel2 setText:@"This image is 176KB in size"]; } else { [imageLabel2 setText:@"Img size: 176KB"]; } - [imageLabel2 setTextAlignment:UITextAlignmentCenter]; + [imageLabel2 setTextAlignment:NSTextAlignmentCenter]; [imageLabel2 setFont:[UIFont systemFontOfSize:11]]; [imageLabel2 setBackgroundColor:[UIColor clearColor]]; [cell addSubview:imageLabel2]; - imageView3 = [[[UIImageView alloc] initWithFrame:CGRectZero] autorelease]; + imageView3 = [[UIImageView alloc] initWithFrame:CGRectZero]; [imageView3 setBackgroundColor:[UIColor grayColor]]; [cell addSubview:imageView3]; - imageProgressIndicator3 = [[[UIProgressView alloc] initWithFrame:CGRectZero] autorelease]; + imageProgressIndicator3 = [[UIProgressView alloc] initWithFrame:CGRectZero]; [cell addSubview:imageProgressIndicator3]; - imageLabel3 = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; + imageLabel3 = [[UILabel alloc] initWithFrame:CGRectZero]; if (tableWidth > 480) { [imageLabel3 setText:@"This image is 1.4MB in size"]; } else { [imageLabel3 setText:@"Img size: 1.4MB"]; } - [imageLabel3 setTextAlignment:UITextAlignmentCenter]; + [imageLabel3 setTextAlignment:NSTextAlignmentCenter]; [imageLabel3 setFont:[UIFont systemFontOfSize:11]]; [imageLabel3 setBackgroundColor:[UIColor clearColor]]; [cell addSubview:imageLabel3]; diff --git a/iPhone Sample/RequestProgressCell.m b/iPhone Sample/RequestProgressCell.m index 94033e68..a9d1142e 100644 --- a/iPhone Sample/RequestProgressCell.m +++ b/iPhone Sample/RequestProgressCell.m @@ -13,21 +13,15 @@ @implementation RequestProgressCell + (id)cell { - RequestProgressCell *cell = [[[RequestProgressCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"RequestProgressCell"] autorelease]; - [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; + RequestProgressCell *cell = [[RequestProgressCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"RequestProgressCell"]; + [[cell textLabel] setTextAlignment:NSTextAlignmentLeft]; [[cell textLabel] setFont:[UIFont systemFontOfSize:12]]; - [[cell textLabel] setLineBreakMode:UILineBreakModeMiddleTruncation]; - [cell setProgressView:[[[UIProgressView alloc] initWithFrame:CGRectMake(0,0,100,20)] autorelease]]; + [[cell textLabel] setLineBreakMode:NSLineBreakByTruncatingMiddle]; + [cell setProgressView:[[UIProgressView alloc] initWithFrame:CGRectMake(0,0,100,20)]]; [cell setAccessoryView:[cell progressView]]; return cell; } -- (void)dealloc -{ - [progressView release]; - [super dealloc]; -} - - (void)layoutSubviews { [super layoutSubviews]; diff --git a/iPhone Sample/Resources/Sample.xib b/iPhone Sample/Resources/Sample.xib index 0e923b76..df63adc2 100644 --- a/iPhone Sample/Resources/Sample.xib +++ b/iPhone Sample/Resources/Sample.xib @@ -1,349 +1,46 @@ - - - 800 - 10F569 - 788 - 1038.29 - 461.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 117 - - - YES - - - - YES - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - YES - - YES - - - YES - - - - YES - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - - 292 - - YES - - - 290 - {320, 44} - - IBCocoaTouchFramework - - YES - - - Title - IBCocoaTouchFramework - - - - - - 274 - {{0, 44}, {320, 387}} - - - 10 - - 549453824 - {84, 1} - - YES - - YES - - - - TU0AKgAAAVjFzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ -y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ -xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ -xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ -xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ -xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P8ADQEAAAMAAAABAFQAAAEB -AAMAAAABAAEAAAECAAMAAAAEAAAB+gEDAAMAAAABAAEAAAEGAAMAAAABAAIAAAERAAQAAAABAAAACAES -AAMAAAABAAEAAAEVAAMAAAABAAQAAAEWAAMAAAABAAEAAAEXAAQAAAABAAABUAEcAAMAAAABAAEAAAFS -AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA - - - - - - 3 - MCAwAA - - - groupTableViewBackgroundColor - - YES - IBCocoaTouchFramework - YES - 1 - 2 - 0 - YES - 44 - 10 - 10 - - - {320, 431} - - - 3 - MQA - - 2 - - - IBCocoaTouchFramework - - - - - YES - - - dataSource - - - - 23 - - - - delegate - - - - 24 - - - - view - - - - 25 - - - - tableView - - - - 27 - - - - navigationBar - - - - 30 - - - - - YES - - 0 - - - - - - -1 - - - File's Owner - - - -2 - - - - - 18 - - - YES - - - - - - - 28 - - - YES - - - - - - 29 - - - - - 16 - - - - - - - YES - - YES - -1.CustomClassName - -2.CustomClassName - 16.IBEditorWindowLastContentRect - 16.IBPluginDependency - 18.IBEditorWindowLastContentRect - 18.IBPluginDependency - 28.IBPluginDependency - 29.IBPluginDependency - - - YES - SynchronousViewController - UIResponder - {{329, 685}, {320, 460}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - {{355, 500}, {320, 431}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - YES - - - YES - - - - - YES - - - YES - - - - 30 - - - - YES - - NSObject - - IBProjectSource - External/GHUnit/Project-IPhone/build/Debug-iphonesimulator/GHUNSObject+Swizzle.h - - - - SampleViewController - UIViewController - - YES - - YES - navigationBar - tableView - - - YES - UINavigationBar - UITableView - - - - YES - - YES - navigationBar - tableView - - - YES - - navigationBar - UINavigationBar - - - tableView - UITableView - - - - - IBProjectSource - SampleViewController.h - - - - SynchronousViewController - SampleViewController - - simpleURLFetch: - NSURL - - - simpleURLFetch: - - simpleURLFetch: - NSURL - - - - IBProjectSource - iPhone Sample/SynchronousViewController.h - - - - - 0 - IBCocoaTouchFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - - com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 - - - YES - ../../iPhone.xcodeproj - 3 - 117 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iPhone Sample/Resources/iPadMainWindow.xib b/iPhone Sample/Resources/iPadMainWindow.xib index 829437b2..bb45224b 100644 --- a/iPhone Sample/Resources/iPadMainWindow.xib +++ b/iPhone Sample/Resources/iPadMainWindow.xib @@ -1,462 +1,54 @@ - - - 800 - 10F569 - 788 - 1038.29 - 461.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 117 - - - YES - - - - YES - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - YES - - YES - - - YES - - - - YES - - IBFilesOwner - IBIPadFramework - - - IBFirstResponder - IBIPadFramework - - - IBIPadFramework - - - - 1316 - - {768, 1024} - - 1 - MSAxIDEAA - - NO - NO - - 2 - - IBIPadFramework - YES - - - - - 2 - - - 3 - - IBIPadFramework - YES - - - - 2 - - - 1 - - IBIPadFramework - NO - - - 256 - {0, 0} - YES - YES - IBIPadFramework - - - YES - - - - ASIHTTPRequest Examples - IBIPadFramework - - - - 2 - - - 1 - - IBIPadFramework - NO - NO - - - - - - Sample - - 2 - - - 1 - - IBIPadFramework - NO - - - - - - YES - - - delegate - - - - 5 - - - - window - - - - 96 - - - - delegate - - - - 99 - - - - splitViewController - - - - 100 - - - - splitViewController - - - - 102 - - - - - YES - - 0 - - - - - - 2 - - - YES - - - - - -1 - - - File's Owner - - - 4 - - - App Delegate - - - -2 - - - - - 87 - - - YES - - - - - - - 88 - - - YES - - - - - - - 90 - - - YES - - - - - - 91 - - - - - 92 - - - - - 60 - - - YES - - - - - - - YES - - YES - -1.CustomClassName - -2.CustomClassName - 2.IBAttributePlaceholdersKey - 2.IBEditorWindowLastContentRect - 2.IBPluginDependency - 2.UIWindow.visibleAtLaunch - 4.CustomClassName - 4.IBPluginDependency - 60.CustomClassName - 60.IBPluginDependency - 87.IBEditorWindowLastContentRect - 87.IBPluginDependency - 88.IBPluginDependency - 90.CustomClassName - 90.IBPluginDependency - 91.IBPluginDependency - 92.IBPluginDependency - - - YES - UIApplication - UIResponder - - YES - - - YES - - - {{682, 13}, {768, 1024}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - iPadSampleAppDelegate - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - SynchronousViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - {{571, 157}, {1024, 768}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - RootViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - YES - - - YES - - - - - YES - - - YES - - - - 102 - - - - YES - - NSObject - - IBProjectSource - External/GHUnit/Project-IPhone/build/Debug-iphonesimulator/GHUNSObject+Swizzle.h - - - - RootViewController - UITableViewController - - splitViewController - UISplitViewController - - - splitViewController - - splitViewController - UISplitViewController - - - - IBProjectSource - iPhone Sample/RootViewController.h - - - - SampleViewController - UIViewController - - YES - - YES - navigationBar - tableView - - - YES - UINavigationBar - UITableView - - - - YES - - YES - navigationBar - tableView - - - YES - - navigationBar - UINavigationBar - - - tableView - UITableView - - - - - IBProjectSource - iPhone Sample/SampleViewController.h - - - - SynchronousViewController - SampleViewController - - simpleURLFetch: - id - - - simpleURLFetch: - - simpleURLFetch: - id - - - - IBProjectSource - iPhone Sample/SynchronousViewController.h - - - - iPadSampleAppDelegate - NSObject - - YES - - YES - splitViewController - window - - - YES - UISplitViewController - UIWindow - - - - YES - - YES - splitViewController - window - - - YES - - splitViewController - UISplitViewController - - - window - UIWindow - - - - - IBProjectSource - iPhone Sample/iPadSampleAppDelegate.h - - - - - 0 - IBIPadFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - - com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 - - - YES - ../../iPhone.xcodeproj - 3 - 117 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iPhone Sample/Resources/iPhoneMainWindow.xib b/iPhone Sample/Resources/iPhoneMainWindow.xib index c989737c..30a4f14c 100644 --- a/iPhone Sample/Resources/iPhoneMainWindow.xib +++ b/iPhone Sample/Resources/iPhoneMainWindow.xib @@ -1,647 +1,79 @@ - - - 528 - 10F569 - 804 - 1038.29 - 461.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 123 - - - YES - - - - - YES - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - YES - - YES - - - YES - - - - YES - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - IBCocoaTouchFramework - - - - 1316 - - YES - - - 1316 - {{6, 20}, {280, 21}} - - - 1 - MSAxIDEgMAA - - NO - YES - NO - IBCocoaTouchFramework - - - Helvetica-Bold - 11 - 16 - - - 1 - MSAxIDEAA - - - 1 - MCAwIDAgMC41MQA - - 1 - 10 - - - - {320, 480} - - - NO - NO - - IBCocoaTouchFramework - YES - - - - - - 1 - - IBCocoaTouchFramework - NO - - Web Page - - Web Page - IBCocoaTouchFramework - - - - - Sample - - 1 - - IBCocoaTouchFramework - NO - - - YES - - - Synchronous - IBCocoaTouchFramework - - - - Sample - - 1 - - IBCocoaTouchFramework - NO - - - - Queue - IBCocoaTouchFramework - - - - Sample - - 1 - - IBCocoaTouchFramework - NO - - - - Upload - IBCocoaTouchFramework - - - - Sample - - 1 - - IBCocoaTouchFramework - NO - - - Authentication - - Authentication - IBCocoaTouchFramework - - - - - Sample - - 1 - - IBCocoaTouchFramework - NO - - - - - - 266 - {{129, 330}, {163, 49}} - - 3 - MCAwAA - - NO - IBCocoaTouchFramework - - - - - - YES - - - window - - - - 9 - - - - delegate - - - - 99 - - - - tabBarController - - - - 147 - - - - - YES - - 0 - - - - - - 2 - - - YES - - - - - - -1 - - - File's Owner - - - 3 - - - - - 106 - - - YES - - - - - - - - - - - 107 - - - - - 108 - - - YES - - - - - - 109 - - - YES - - - - - - 110 - - - - - 111 - - - - - -2 - - - - - 124 - - - YES - - - - - - 125 - - - - - 126 - - - YES - - - - - - 127 - - - - - 128 - - - - - 148 - - - YES - - - - - - 149 - - - - - - - YES - - YES - -1.CustomClassName - -2.CustomClassName - 106.IBEditorWindowLastContentRect - 106.IBPluginDependency - 107.IBPluginDependency - 108.CustomClassName - 108.IBPluginDependency - 109.CustomClassName - 109.IBPluginDependency - 110.IBPluginDependency - 111.IBPluginDependency - 124.CustomClassName - 126.CustomClassName - 128.IBPluginDependency - 148.CustomClassName - 2.IBAttributePlaceholdersKey - 2.IBEditorWindowLastContentRect - 2.IBPluginDependency - 3.CustomClassName - 3.IBPluginDependency - - - YES - UIApplication - UIResponder - {{997, 296}, {320, 480}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - SynchronousViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - QueueViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UploadViewController - AuthenticationViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - WebPageViewController - - YES - - - YES - - - {{1019, 29}, {320, 480}} - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - iPhoneSampleAppDelegate - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - YES - - - YES - - - - - YES - - - YES - - - - 149 - - - - YES - - AuthenticationViewController - SampleViewController - - fetchTopSecretInformation: - id - - - fetchTopSecretInformation: - - fetchTopSecretInformation: - id - - - - IBProjectSource - iPhone Sample/AuthenticationViewController.h - - - - NSObject - - IBProjectSource - External/GHUnit/Project-IPhone/build/Debug-iphonesimulator/GHUNSObject+Swizzle.h - - - - QueueViewController - SampleViewController - - fetchThreeImages: - id - - - fetchThreeImages: - - fetchThreeImages: - id - - - - IBProjectSource - iPhone Sample/QueueViewController.h - - - - SampleViewController - UIViewController - - YES - - YES - navigationBar - tableView - - - YES - UINavigationBar - UITableView - - - - YES - - YES - navigationBar - tableView - - - YES - - navigationBar - UINavigationBar - - - tableView - UITableView - - - - - IBProjectSource - iPhone Sample/SampleViewController.h - - - - SynchronousViewController - SampleViewController - - simpleURLFetch: - id - - - simpleURLFetch: - - simpleURLFetch: - id - - - - IBProjectSource - iPhone Sample/SynchronousViewController.h - - - - UploadViewController - SampleViewController - - YES - - YES - performLargeUpload: - toggleThrottling: - - - YES - id - id - - - - YES - - YES - performLargeUpload: - toggleThrottling: - - - YES - - performLargeUpload: - id - - - toggleThrottling: - id - - - - - progressIndicator - UIProgressView - - - progressIndicator - - progressIndicator - UIProgressView - - - - IBProjectSource - iPhone Sample/UploadViewController.h - - - - WebPageViewController - SampleViewController - - IBProjectSource - iPhone Sample/WebPageViewController.h - - - - iPhoneSampleAppDelegate - NSObject - - YES - - YES - tabBarController - window - - - YES - UITabBarController - UIWindow - - - - YES - - YES - tabBarController - window - - - YES - - tabBarController - UITabBarController - - - window - UIWindow - - - - - IBProjectSource - iPhone Sample/iPhoneSampleAppDelegate.h - - - - - 0 - IBCocoaTouchFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - - com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 - - - YES - ../../iPhone.xcodeproj - 3 - 123 - - + + + + + + + + + + + + Helvetica-Bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iPhone Sample/RootViewController.h b/iPhone Sample/RootViewController.h index 6d2cacdf..f2193103 100644 --- a/iPhone Sample/RootViewController.h +++ b/iPhone Sample/RootViewController.h @@ -8,11 +8,7 @@ #import -@interface RootViewController : UITableViewController { - UISplitViewController *splitViewController; - UIPopoverController *popoverController; - UIBarButtonItem *rootPopoverButtonItem; -} +@interface RootViewController : UITableViewController @property (nonatomic, assign) IBOutlet UISplitViewController *splitViewController; @property (nonatomic, retain) UIPopoverController *popoverController; @property (nonatomic, retain) UIBarButtonItem *rootPopoverButtonItem; diff --git a/iPhone Sample/RootViewController.m b/iPhone Sample/RootViewController.m index a08980e2..463c71db 100644 --- a/iPhone Sample/RootViewController.m +++ b/iPhone Sample/RootViewController.m @@ -30,7 +30,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"]; } switch ([indexPath row]) { case 0: @@ -62,19 +62,19 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath UIViewController *viewController = nil; switch ([indexPath row]) { case 0: - viewController = [[[SynchronousViewController alloc] initWithNibName:@"Sample" bundle:nil] autorelease]; + viewController = [[SynchronousViewController alloc] initWithNibName:@"Sample" bundle:nil]; break; case 1: - viewController = [[[QueueViewController alloc] initWithNibName:@"Sample" bundle:nil] autorelease]; + viewController = [[QueueViewController alloc] initWithNibName:@"Sample" bundle:nil]; break; case 2: - viewController = [[[AuthenticationViewController alloc] initWithNibName:@"Sample" bundle:nil] autorelease]; + viewController = [[AuthenticationViewController alloc] initWithNibName:@"Sample" bundle:nil]; break; case 3: - viewController = [[[UploadViewController alloc] initWithNibName:@"Sample" bundle:nil] autorelease]; + viewController = [[UploadViewController alloc] initWithNibName:@"Sample" bundle:nil]; break; case 4: - viewController = [[[WebPageViewController alloc] initWithNibName:@"Sample" bundle:nil] autorelease]; + viewController = [[WebPageViewController alloc] initWithNibName:@"Sample" bundle:nil]; break; } [splitViewController setViewControllers:[NSArray arrayWithObjects:[self navigationController],viewController,nil]]; @@ -115,13 +115,6 @@ - (void)splitViewController:(UISplitViewController *)svc popoverController: (UIP } } -- (void)dealloc -{ - [popoverController release]; - [rootPopoverButtonItem release]; - [super dealloc]; -} - @synthesize splitViewController; @synthesize popoverController; @synthesize rootPopoverButtonItem; diff --git a/iPhone Sample/SampleViewController.m b/iPhone Sample/SampleViewController.m index 74312994..566d593f 100644 --- a/iPhone Sample/SampleViewController.m +++ b/iPhone Sample/SampleViewController.m @@ -78,11 +78,8 @@ - (void)keyboardWillHide:(NSNotification *)notification } - (void)dealloc { - [navigationBar release]; - [tableView release]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; - [super dealloc]; } @synthesize navigationBar; diff --git a/iPhone Sample/SynchronousViewController.m b/iPhone Sample/SynchronousViewController.m index 2c5c72ee..f23d6c9b 100644 --- a/iPhone Sample/SynchronousViewController.m +++ b/iPhone Sample/SynchronousViewController.m @@ -48,8 +48,6 @@ - (void)viewDidLoad - (void)dealloc { [request cancel]; - [request release]; - [super dealloc]; } @@ -76,8 +74,8 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath } else if ([indexPath section] == 1) { cell = [tableView dequeueReusableCellWithIdentifier:@"URLCell"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"URLCell"] autorelease]; - urlField = [[[UITextField alloc] initWithFrame:CGRectZero] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"URLCell"]; + urlField = [[UITextField alloc] initWithFrame:CGRectZero]; [[cell contentView] addSubview:urlField]; goButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [goButton setTitle:@"Go!" forState:UIControlStateNormal]; @@ -97,8 +95,8 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath } else if ([indexPath section] == 2) { cell = [tableView dequeueReusableCellWithIdentifier:@"ResponseCell"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ResponseCell"] autorelease]; - responseField = [[[UITextView alloc] initWithFrame:CGRectZero] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ResponseCell"]; + responseField = [[UITextView alloc] initWithFrame:CGRectZero]; [responseField setBackgroundColor:[UIColor clearColor]]; [[cell contentView] addSubview:responseField]; } @@ -116,7 +114,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath if (!cell) { cell = [DetailCell cell]; } - NSString *key = [[[request responseHeaders] allKeys] objectAtIndex:[indexPath row]]; + NSString *key = [[[request responseHeaders] allKeys] objectAtIndex:(NSUInteger)[indexPath row]]; [[cell textLabel] setText:key]; [[cell detailTextLabel] setText:[[request responseHeaders] objectForKey:key]]; } @@ -127,7 +125,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath - (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section { if (section == 3) { - return [[request responseHeaders] count]; + return (NSInteger)[[request responseHeaders] count]; } else { return 1; } diff --git a/iPhone Sample/Tests-Info.plist b/iPhone Sample/Tests-Info.plist index 2915c791..509ed379 100644 --- a/iPhone Sample/Tests-Info.plist +++ b/iPhone Sample/Tests-Info.plist @@ -11,7 +11,7 @@ CFBundleIconFile iphone-tests-icon.png CFBundleIdentifier - com.allseeinginteractive.asihttprequest.tests + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/iPhone Sample/ToggleCell.h b/iPhone Sample/ToggleCell.h index 743d628b..8d656e18 100644 --- a/iPhone Sample/ToggleCell.h +++ b/iPhone Sample/ToggleCell.h @@ -9,9 +9,8 @@ #import -@interface ToggleCell : UITableViewCell { - UISwitch *toggle; -} +@interface ToggleCell : UITableViewCell + + (id)cell; @property (assign, nonatomic) UISwitch *toggle; diff --git a/iPhone Sample/ToggleCell.m b/iPhone Sample/ToggleCell.m index 321a1a50..1365f0ce 100644 --- a/iPhone Sample/ToggleCell.m +++ b/iPhone Sample/ToggleCell.m @@ -13,12 +13,11 @@ @implementation ToggleCell + (id)cell { - ToggleCell *cell = [[[ToggleCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ToggleCell"] autorelease]; - [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; - [cell setToggle:[[[UISwitch alloc] initWithFrame:CGRectMake(0,0,20,20)] autorelease]]; + ToggleCell *cell = [[ToggleCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ToggleCell"]; + [[cell textLabel] setTextAlignment:NSTextAlignmentLeft]; + [cell setToggle:[[UISwitch alloc] initWithFrame:CGRectMake(0,0,20,20)]]; [cell setAccessoryView:[cell toggle]]; return cell; } -@synthesize toggle; @end diff --git a/iPhone Sample/UploadViewController.m b/iPhone Sample/UploadViewController.m index e3a8ec63..8d1066fa 100644 --- a/iPhone Sample/UploadViewController.m +++ b/iPhone Sample/UploadViewController.m @@ -36,7 +36,7 @@ - (IBAction)performLargeUpload:(id)sender [request setDidFinishSelector:@selector(uploadFinished:)]; //Create a 256KB file - NSData *data = [[[NSMutableData alloc] initWithLength:256*1024] autorelease]; + NSData *data = [[NSMutableData alloc] initWithLength:256*1024]; NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"file"]; [data writeToFile:path atomically:NO]; @@ -70,7 +70,7 @@ - (void)uploadFinished:(ASIHTTPRequest *)theRequest [[UIApplication sharedApplication] cancelAllLocalNotifications]; // Create a new notification - UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease]; + UILocalNotification *notification = [[UILocalNotification alloc] init]; if (notification) { [notification setFireDate:[NSDate date]]; [notification setTimeZone:[NSTimeZone defaultTimeZone]]; @@ -87,10 +87,6 @@ - (void)dealloc [request setDelegate:nil]; [request setUploadProgressDelegate:nil]; [request cancel]; - [request release]; - [progressIndicator release]; - [resultView release]; - [super dealloc]; } /* @@ -117,7 +113,7 @@ - (UIView *)tableView:(UITableView *)theTableView viewForHeaderInSection:(NSInte tablePadding = 110; } - UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)] autorelease]; + UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)]; UIButton *goButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [goButton setTitle:@"Go!" forState:UIControlStateNormal]; [goButton sizeToFit]; @@ -156,7 +152,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath } else { cell = [tableView dequeueReusableCellWithIdentifier:@"Response"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"]; [[cell contentView] addSubview:resultView]; } [resultView setFrame:CGRectMake(5,5,tableWidth-tablePadding,60)]; diff --git a/iPhone Sample/WebPageViewController.m b/iPhone Sample/WebPageViewController.m index db982dc7..1c907293 100644 --- a/iPhone Sample/WebPageViewController.m +++ b/iPhone Sample/WebPageViewController.m @@ -118,7 +118,7 @@ - (void)requestFinished:(ASIWebPageRequest *)theRequest - (void)request:(ASIHTTPRequest *)theRequest didReceiveBytes:(long long)newLength { - NSInteger requestNumber = [[self requestsInProgress] indexOfObject:theRequest]; + NSInteger requestNumber = (NSInteger)[[self requestsInProgress] indexOfObject:theRequest]; if (requestNumber != NSNotFound) { RequestProgressCell *cell = (RequestProgressCell *)[[self tableView] cellForRowAtIndexPath:[NSIndexPath indexPathForRow:requestNumber inSection:2]]; if ([theRequest contentLength]+[theRequest partialDownloadSize] > 0) { @@ -142,13 +142,7 @@ - (void)dealloc [request setDelegate:nil]; [request setDownloadProgressDelegate:nil]; [request cancel]; - [request release]; [webView setDelegate:nil]; - [webView release]; - [responseField release]; - [urlField release]; - [requestsInProgress release]; - [super dealloc]; } - (void)viewDidLoad @@ -191,7 +185,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath if ([indexPath row] == 0) { cell = [tableView dequeueReusableCellWithIdentifier:@"WebPageCell"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WebPageCell"] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WebPageCell"]; [[cell contentView] addSubview:webView]; } [webView setFrame:CGRectMake(10,10,tableWidth-tablePadding,280)]; @@ -231,7 +225,7 @@ - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath cell = [tableView dequeueReusableCellWithIdentifier:@"Response"]; if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"]; [[cell contentView] addSubview:responseField]; } @@ -252,7 +246,7 @@ - (UIView *)tableView:(UITableView *)theTableView viewForHeaderInSection:(NSInte tablePadding = 110; } - UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)] autorelease]; + UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableWidth-(tablePadding/2),30)]; UIButton *clearCacheButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [clearCacheButton setTitle:@"Clear Cache" forState:UIControlStateNormal]; diff --git a/iPhone Sample/iPadInfo.plist b/iPhone Sample/iPadInfo.plist index d0605f97..ac9d06fb 100644 --- a/iPhone Sample/iPadInfo.plist +++ b/iPhone Sample/iPadInfo.plist @@ -11,7 +11,7 @@ CFBundleIconFile iphone-icon.png CFBundleIdentifier - com.allseeinginteractive.asihttprequest.ipad.sample + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/iPhone Sample/iPadSampleAppDelegate.m b/iPhone Sample/iPadSampleAppDelegate.m index 7d028d95..b24034e0 100644 --- a/iPhone Sample/iPadSampleAppDelegate.m +++ b/iPhone Sample/iPadSampleAppDelegate.m @@ -12,17 +12,10 @@ @implementation iPadSampleAppDelegate - (void)applicationDidFinishLaunching:(UIApplication *)application { - [window addSubview:[splitViewController view]]; + window.rootViewController = splitViewController; [window makeKeyAndVisible]; } -- (void)dealloc { - [splitViewController release]; - [window release]; - [super dealloc]; -} - - @synthesize window; @synthesize splitViewController; @end diff --git a/iPhone Sample/iPhoneInfo.plist b/iPhone Sample/iPhoneInfo.plist index e47caae1..6829a659 100644 --- a/iPhone Sample/iPhoneInfo.plist +++ b/iPhone Sample/iPhoneInfo.plist @@ -11,7 +11,7 @@ CFBundleIconFile iphone-icon.png CFBundleIdentifier - com.allseeinginteractive.asihttprequest.iphone.sample + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/iPhone Sample/iPhoneSampleAppDelegate.m b/iPhone Sample/iPhoneSampleAppDelegate.m index 04bdf000..558a6e04 100644 --- a/iPhone Sample/iPhoneSampleAppDelegate.m +++ b/iPhone Sample/iPhoneSampleAppDelegate.m @@ -13,13 +13,7 @@ @implementation iPhoneSampleAppDelegate - (void)applicationDidFinishLaunching:(UIApplication *)application { [[tabBarController view] setFrame:CGRectMake(0, 0, 320, 480)]; - [window addSubview:[tabBarController view]]; -} - -- (void)dealloc -{ - [window release]; - [super dealloc]; + window.rootViewController = tabBarController; } @synthesize window; diff --git a/iPhone Sample/main.m b/iPhone Sample/main.m index 1dea1181..c53a382d 100644 --- a/iPhone Sample/main.m +++ b/iPhone Sample/main.m @@ -7,11 +7,11 @@ // #import +#import "iPhoneSampleAppDelegate.h" int main(int argc, char *argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, nil); - [pool release]; - return retVal; + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([iPhoneSampleAppDelegate class])); + } } diff --git a/iPhone.xcodeproj/project.pbxproj b/iPhone.xcodeproj/project.pbxproj index 704320fe..a241054c 100644 --- a/iPhone.xcodeproj/project.pbxproj +++ b/iPhone.xcodeproj/project.pbxproj @@ -7,32 +7,32 @@ objects = { /* Begin PBXBuildFile section */ + 944E25951FB9F12900D68549 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 944E25941FB9F12900D68549 /* Default-568h@2x.png */; }; + 944E25961FB9F13300D68549 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 944E25941FB9F12900D68549 /* Default-568h@2x.png */; }; + 94CD355C1FB9F96300418203 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94CD355B1FB9F96300418203 /* QuartzCore.framework */; }; B50C1823121C26DB0055FCAB /* ClientCertificateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B50C1822121C26DB0055FCAB /* ClientCertificateTests.m */; }; B50C182C121C26FA0055FCAB /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B50C182B121C26FA0055FCAB /* Security.framework */; }; B50C1848121C27510055FCAB /* client.p12 in Resources */ = {isa = PBXBuildFile; fileRef = B50C1847121C27510055FCAB /* client.p12 */; }; - B50D532C126C87ED0022EA6F /* BlocksTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B50D532B126C87ED0022EA6F /* BlocksTests.m */; }; - B50F66191297FA45003887B1 /* strict.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B50F66181297FA45003887B1 /* strict.xcconfig */; }; - B50F661A1297FA45003887B1 /* strict.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B50F66181297FA45003887B1 /* strict.xcconfig */; }; - B50F661B1297FA45003887B1 /* strict.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = B50F66181297FA45003887B1 /* strict.xcconfig */; }; - B51791A31024C3E800583567 /* AuthenticationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B51791A21024C3E800583567 /* AuthenticationViewController.m */; }; - B51A1A9B11DDF85100ED75CF /* ASIDownloadCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B51A1A7A11DDF7BF00ED75CF /* ASIDownloadCacheTests.m */; }; + B50D532C126C87ED0022EA6F /* BlocksTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B50D532B126C87ED0022EA6F /* BlocksTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B51791A31024C3E800583567 /* AuthenticationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B51791A21024C3E800583567 /* AuthenticationViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B51A1A9B11DDF85100ED75CF /* ASIDownloadCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B51A1A7A11DDF7BF00ED75CF /* ASIDownloadCacheTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B522DACE1030B2AB009A2D22 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = B522DACD1030B2AB009A2D22 /* ASIInputStream.m */; }; B522DACF1030B2AB009A2D22 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = B522DACD1030B2AB009A2D22 /* ASIInputStream.m */; }; B523254211CA01F1006C6E5A /* Sample.xib in Resources */ = {isa = PBXBuildFile; fileRef = B523254111CA01F1006C6E5A /* Sample.xib */; }; B523254311CA01F1006C6E5A /* Sample.xib in Resources */ = {isa = PBXBuildFile; fileRef = B523254111CA01F1006C6E5A /* Sample.xib */; }; B52325AD11CA05A8006C6E5A /* info.png in Resources */ = {isa = PBXBuildFile; fileRef = B52325AC11CA05A8006C6E5A /* info.png */; }; - B5254FF91025F9BF00CF7BC4 /* ProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5254FF71025F9BF00CF7BC4 /* ProxyTests.m */; }; - B52D4A2F10DA4ED5008E8365 /* PerformanceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B52D4A2E10DA4ED5008E8365 /* PerformanceTests.m */; }; + B5254FF91025F9BF00CF7BC4 /* ProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5254FF71025F9BF00CF7BC4 /* ProxyTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B52D4A2F10DA4ED5008E8365 /* PerformanceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B52D4A2E10DA4ED5008E8365 /* PerformanceTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B53E6D951257B45800C1E79A /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E6D911257B45800C1E79A /* ASIDataDecompressor.m */; }; B53E6D961257B45800C1E79A /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E6D931257B45800C1E79A /* ASIDataCompressor.m */; }; B53E6D971257B45800C1E79A /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E6D911257B45800C1E79A /* ASIDataDecompressor.m */; }; B53E6D981257B45800C1E79A /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E6D931257B45800C1E79A /* ASIDataCompressor.m */; }; B53E6D991257B45800C1E79A /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E6D911257B45800C1E79A /* ASIDataDecompressor.m */; }; B53E6D9A1257B45800C1E79A /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E6D931257B45800C1E79A /* ASIDataCompressor.m */; }; - B540400B115114BA00D8BE63 /* ASIS3Bucket.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404000115114BA00D8BE63 /* ASIS3Bucket.m */; }; - B540400C115114BA00D8BE63 /* ASIS3BucketRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404002115114BA00D8BE63 /* ASIS3BucketRequest.m */; }; - B540400D115114BA00D8BE63 /* ASIS3ObjectRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404004115114BA00D8BE63 /* ASIS3ObjectRequest.m */; }; - B540400E115114BA00D8BE63 /* ASIS3ServiceRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404006115114BA00D8BE63 /* ASIS3ServiceRequest.m */; }; + B540400B115114BA00D8BE63 /* ASIS3Bucket.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404000115114BA00D8BE63 /* ASIS3Bucket.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B540400C115114BA00D8BE63 /* ASIS3BucketRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404002115114BA00D8BE63 /* ASIS3BucketRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B540400D115114BA00D8BE63 /* ASIS3ObjectRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404004115114BA00D8BE63 /* ASIS3ObjectRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B540400E115114BA00D8BE63 /* ASIS3ServiceRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5404006115114BA00D8BE63 /* ASIS3ServiceRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B55252B411D22E2200F9B170 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B55252B311D22E2200F9B170 /* Reachability.m */; }; B55252B511D22E2200F9B170 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B55252B311D22E2200F9B170 /* Reachability.m */; }; B55252B611D22E2200F9B170 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B55252B311D22E2200F9B170 /* Reachability.m */; }; @@ -40,19 +40,19 @@ B55B604D0F765A320064029C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60460F765A320064029C /* ASIFormDataRequest.m */; }; B55B604E0F765A320064029C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60480F765A320064029C /* ASIHTTPRequest.m */; }; B55B604F0F765A320064029C /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604A0F765A320064029C /* ASINetworkQueue.m */; }; - B55B60620F765A750064029C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60600F765A750064029C /* main.m */; }; - B55B606F0F765A930064029C /* QueueViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60670F765A930064029C /* QueueViewController.m */; }; - B55B60700F765A930064029C /* SynchronousViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606A0F765A930064029C /* SynchronousViewController.m */; }; - B55B60710F765A930064029C /* iPhoneSampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606B0F765A930064029C /* iPhoneSampleAppDelegate.m */; }; - B55B60720F765A930064029C /* UploadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606C0F765A930064029C /* UploadViewController.m */; }; + B55B60620F765A750064029C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60600F765A750064029C /* main.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B55B606F0F765A930064029C /* QueueViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60670F765A930064029C /* QueueViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B55B60700F765A930064029C /* SynchronousViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606A0F765A930064029C /* SynchronousViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B55B60710F765A930064029C /* iPhoneSampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606B0F765A930064029C /* iPhoneSampleAppDelegate.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B55B60720F765A930064029C /* UploadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606C0F765A930064029C /* UploadViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B55B60740F765A990064029C /* iphone-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = B55B60730F765A990064029C /* iphone-icon.png */; }; B55B60CF0F765BBA0064029C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60460F765A320064029C /* ASIFormDataRequest.m */; }; B55B60D00F765BBD0064029C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60480F765A320064029C /* ASIHTTPRequest.m */; }; B55B60D10F765BC00064029C /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604A0F765A320064029C /* ASINetworkQueue.m */; }; - B55B60D30F765BC90064029C /* ASIFormDataRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60530F765A3C0064029C /* ASIFormDataRequestTests.m */; }; - B55B60D40F765BCD0064029C /* ASIHTTPRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60550F765A3C0064029C /* ASIHTTPRequestTests.m */; }; - B55B60D50F765BD00064029C /* ASINetworkQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60570F765A3C0064029C /* ASINetworkQueueTests.m */; }; - B5652920101C8BD7000499CF /* ASITestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = B565291F101C8BD7000499CF /* ASITestCase.m */; }; + B55B60D30F765BC90064029C /* ASIFormDataRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60530F765A3C0064029C /* ASIFormDataRequestTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B55B60D40F765BCD0064029C /* ASIHTTPRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60550F765A3C0064029C /* ASIHTTPRequestTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B55B60D50F765BD00064029C /* ASINetworkQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60570F765A3C0064029C /* ASINetworkQueueTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5652920101C8BD7000499CF /* ASITestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = B565291F101C8BD7000499CF /* ASITestCase.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B56529A3101C8EDA000499CF /* iphone-tests-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = B56529A2101C8EDA000499CF /* iphone-tests-icon.png */; }; B576D4C111C7CC970059B815 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B576D4C011C7CC970059B815 /* CFNetwork.framework */; }; B576D4C411C7CC9C0059B815 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B576D4C311C7CC9C0059B815 /* UIKit.framework */; }; @@ -74,39 +74,39 @@ B576D71611C7F34D0059B815 /* ASIAuthenticationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = B59A87C1103EC6F200300252 /* ASIAuthenticationDialog.m */; }; B576D71D11C7F34D0059B815 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B576D52C11C7CEFA0059B815 /* Foundation.framework */; }; B576D76611C7F4D90059B815 /* iPhoneMainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = B576D76511C7F4D90059B815 /* iPhoneMainWindow.xib */; }; - B57AF5921258B3F1002A1F0C /* WebPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B57AF5911258B3F1002A1F0C /* WebPageViewController.m */; }; + B57AF5921258B3F1002A1F0C /* WebPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B57AF5911258B3F1002A1F0C /* WebPageViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B57AF5931258B3F1002A1F0C /* WebPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B57AF5911258B3F1002A1F0C /* WebPageViewController.m */; }; - B57AF5961258B401002A1F0C /* RequestProgressCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B57AF5951258B401002A1F0C /* RequestProgressCell.m */; }; + B57AF5961258B401002A1F0C /* RequestProgressCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B57AF5951258B401002A1F0C /* RequestProgressCell.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B57AF5971258B401002A1F0C /* RequestProgressCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B57AF5951258B401002A1F0C /* RequestProgressCell.m */; }; B57D0F4812AA7D3600E5F992 /* ASIWebPageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B57D0F4712AA7D3600E5F992 /* ASIWebPageRequest.m */; }; B57D0F4912AA7D3600E5F992 /* ASIWebPageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B57D0F4712AA7D3600E5F992 /* ASIWebPageRequest.m */; }; B57D0F4A12AA7D3600E5F992 /* ASIWebPageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B57D0F4712AA7D3600E5F992 /* ASIWebPageRequest.m */; }; B581DDCA12FDFEEE003BA9D0 /* GHUnitIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B581DDC912FDFEEE003BA9D0 /* GHUnitIOS.framework */; }; - B5873FD610FF28CA001E145F /* ASIS3BucketObject.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FC210FF28CA001E145F /* ASIS3BucketObject.m */; }; - B5873FD810FF28CA001E145F /* ASIS3Request.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FC610FF28CA001E145F /* ASIS3Request.m */; }; - B5873FD910FF28CA001E145F /* ASICloudFilesCDNRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FC910FF28CA001E145F /* ASICloudFilesCDNRequest.m */; }; - B5873FDA10FF28CA001E145F /* ASICloudFilesContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FCB10FF28CA001E145F /* ASICloudFilesContainer.m */; }; - B5873FDB10FF28CA001E145F /* ASICloudFilesContainerRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FCD10FF28CA001E145F /* ASICloudFilesContainerRequest.m */; }; - B5873FDC10FF28CA001E145F /* ASICloudFilesContainerXMLParserDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FCF10FF28CA001E145F /* ASICloudFilesContainerXMLParserDelegate.m */; }; - B5873FDD10FF28CA001E145F /* ASICloudFilesObject.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FD110FF28CA001E145F /* ASICloudFilesObject.m */; }; - B5873FDE10FF28CA001E145F /* ASICloudFilesObjectRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FD310FF28CA001E145F /* ASICloudFilesObjectRequest.m */; }; - B5873FDF10FF28CA001E145F /* ASICloudFilesRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FD510FF28CA001E145F /* ASICloudFilesRequest.m */; }; - B5873FF510FF2904001E145F /* ASICloudFilesRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FF310FF2904001E145F /* ASICloudFilesRequestTests.m */; }; + B5873FD610FF28CA001E145F /* ASIS3BucketObject.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FC210FF28CA001E145F /* ASIS3BucketObject.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FD810FF28CA001E145F /* ASIS3Request.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FC610FF28CA001E145F /* ASIS3Request.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FD910FF28CA001E145F /* ASICloudFilesCDNRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FC910FF28CA001E145F /* ASICloudFilesCDNRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FDA10FF28CA001E145F /* ASICloudFilesContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FCB10FF28CA001E145F /* ASICloudFilesContainer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FDB10FF28CA001E145F /* ASICloudFilesContainerRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FCD10FF28CA001E145F /* ASICloudFilesContainerRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FDC10FF28CA001E145F /* ASICloudFilesContainerXMLParserDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FCF10FF28CA001E145F /* ASICloudFilesContainerXMLParserDelegate.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FDD10FF28CA001E145F /* ASICloudFilesObject.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FD110FF28CA001E145F /* ASICloudFilesObject.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FDE10FF28CA001E145F /* ASICloudFilesObjectRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FD310FF28CA001E145F /* ASICloudFilesObjectRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FDF10FF28CA001E145F /* ASICloudFilesRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FD510FF28CA001E145F /* ASICloudFilesRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5873FF510FF2904001E145F /* ASICloudFilesRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5873FF310FF2904001E145F /* ASICloudFilesRequestTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B59A87C2103EC6F200300252 /* ASIAuthenticationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = B59A87C1103EC6F200300252 /* ASIAuthenticationDialog.m */; }; B59A87C3103EC6F200300252 /* ASIAuthenticationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = B59A87C1103EC6F200300252 /* ASIAuthenticationDialog.m */; }; B5BD2AFA11CA541100D7C426 /* iPadSampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AF911CA541100D7C426 /* iPadSampleAppDelegate.m */; }; B5BD2B0111CA542000D7C426 /* DetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AFC11CA542000D7C426 /* DetailCell.m */; }; B5BD2B0211CA542000D7C426 /* InfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AFE11CA542000D7C426 /* InfoCell.m */; }; B5BD2B0311CA542000D7C426 /* ToggleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0011CA542000D7C426 /* ToggleCell.m */; }; - B5BD2B0411CA542000D7C426 /* DetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AFC11CA542000D7C426 /* DetailCell.m */; }; - B5BD2B0511CA542000D7C426 /* InfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AFE11CA542000D7C426 /* InfoCell.m */; }; - B5BD2B0611CA542000D7C426 /* ToggleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0011CA542000D7C426 /* ToggleCell.m */; }; + B5BD2B0411CA542000D7C426 /* DetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AFC11CA542000D7C426 /* DetailCell.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5BD2B0511CA542000D7C426 /* InfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2AFE11CA542000D7C426 /* InfoCell.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5BD2B0611CA542000D7C426 /* ToggleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0011CA542000D7C426 /* ToggleCell.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B5BD2B0B11CA542700D7C426 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0811CA542700D7C426 /* RootViewController.m */; }; B5BD2B0C11CA542700D7C426 /* SampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0A11CA542700D7C426 /* SampleViewController.m */; }; - B5BD2B0E11CA542700D7C426 /* SampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0A11CA542700D7C426 /* SampleViewController.m */; }; - B5BF64EF12FDFC7100CBC324 /* GHUnitIOSTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BF64EE12FDFC7100CBC324 /* GHUnitIOSTestMain.m */; }; - B5C6663E100A82D7004F3C96 /* ASIS3RequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C6663D100A82D7004F3C96 /* ASIS3RequestTests.m */; }; - B5EA45AA109B56D800E920CB /* StressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EA45A9109B56D800E920CB /* StressTests.m */; }; + B5BD2B0E11CA542700D7C426 /* SampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BD2B0A11CA542700D7C426 /* SampleViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5BF64EF12FDFC7100CBC324 /* GHUnitIOSTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = B5BF64EE12FDFC7100CBC324 /* GHUnitIOSTestMain.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5C6663E100A82D7004F3C96 /* ASIS3RequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5C6663D100A82D7004F3C96 /* ASIS3RequestTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + B5EA45AA109B56D800E920CB /* StressTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EA45A9109B56D800E920CB /* StressTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; B5FE752711DBBA6400F898C8 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = B5FE752511DBBA6400F898C8 /* ASIDownloadCache.m */; }; B5FE752811DBBA6400F898C8 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = B5FE752511DBBA6400F898C8 /* ASIDownloadCache.m */; }; B5FE752911DBBA6400F898C8 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = B5FE752511DBBA6400F898C8 /* ASIDownloadCache.m */; }; @@ -143,6 +143,8 @@ /* Begin PBXFileReference section */ 1D6058910D05DD3D006BFB54 /* ASIHTTPRequest iPhone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ASIHTTPRequest iPhone.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 944E25941FB9F12900D68549 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 94CD355B1FB9F96300418203 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; B50C1821121C26DB0055FCAB /* ClientCertificateTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientCertificateTests.h; sourceTree = ""; }; B50C1822121C26DB0055FCAB /* ClientCertificateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClientCertificateTests.m; sourceTree = ""; }; B50C182B121C26FA0055FCAB /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; @@ -291,6 +293,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 94CD355C1FB9F96300418203 /* QuartzCore.framework in Frameworks */, B576D4C111C7CC970059B815 /* CFNetwork.framework in Frameworks */, B576D4D111C7CCBC0059B815 /* CoreGraphics.framework in Frameworks */, DADCEB8C12D5046A00958557 /* Foundation.framework in Frameworks */, @@ -366,6 +369,7 @@ 29B97314FDCFA39411CA2CEA /* iPhone */ = { isa = PBXGroup; children = ( + 944E25941FB9F12900D68549 /* Default-568h@2x.png */, B5D1454E1029E20D004379B8 /* External */, 080E96DDFE201D6D7F000001 /* Classes */, 29B97315FDCFA39411CA2CEA /* Other Sources */, @@ -422,6 +426,7 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + 94CD355B1FB9F96300418203 /* QuartzCore.framework */, B581DDC912FDFEEE003BA9D0 /* GHUnitIOS.framework */, B576D4C011C7CC970059B815 /* CFNetwork.framework */, B576D4D011C7CCBC0059B815 /* CoreGraphics.framework */, @@ -616,7 +621,12 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0410; + LastUpgradeCheck = 0910; + TargetAttributes = { + 1D6058900D05DD3D006BFB54 = { + ProvisioningStyle = Automatic; + }; + }; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "iPhone" */; compatibilityVersion = "Xcode 3.2"; @@ -645,9 +655,9 @@ buildActionMask = 2147483647; files = ( B55B60740F765A990064029C /* iphone-icon.png in Resources */, + 944E25961FB9F13300D68549 /* Default-568h@2x.png in Resources */, B576D76611C7F4D90059B815 /* iPhoneMainWindow.xib in Resources */, B523254311CA01F1006C6E5A /* Sample.xib in Resources */, - B50F661A1297FA45003887B1 /* strict.xcconfig in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -657,7 +667,7 @@ files = ( B56529A3101C8EDA000499CF /* iphone-tests-icon.png in Resources */, B50C1848121C27510055FCAB /* client.p12 in Resources */, - B50F661B1297FA45003887B1 /* strict.xcconfig in Resources */, + 944E25951FB9F12900D68549 /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -669,7 +679,6 @@ B558B5EB11C7F9C8009B4627 /* iPadMainWindow.xib in Resources */, B523254211CA01F1006C6E5A /* Sample.xib in Resources */, B52325AD11CA05A8006C6E5A /* info.png in Resources */, - B50F66191297FA45003887B1 /* strict.xcconfig in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -828,10 +837,12 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; + DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -840,9 +851,12 @@ GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "iPhone Sample/iPhoneInfo.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.1.3; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.allseeinginteractive.asihttprequest.iphone.sample; PRODUCT_NAME = "ASIHTTPRequest iPhone"; - "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "1EF820DC-2714-4C87-9291-080265963509"; + PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; @@ -851,18 +865,22 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = YES; + DEVELOPMENT_TEAM = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iPhone Sample/iPhone_Prefix.pch"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "iPhone Sample/iPhoneInfo.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.1.3; + PRODUCT_BUNDLE_IDENTIFIER = com.allseeinginteractive.asihttprequest.iphone.sample; PRODUCT_NAME = "ASIHTTPRequest iPhone"; - "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=iphoneos*]" = "1EF820DC-2714-4C87-9291-080265963509"; + PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = 1; }; name = Release; @@ -872,6 +890,8 @@ baseConfigurationReference = B50F66181297FA45003887B1 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -884,17 +904,20 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iPhone Sample/iPhone_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ""; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "iPhone Sample/Tests-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.2.2; LIBRARY_SEARCH_PATHS = ""; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-ObjC", "-all_load", ); + PRODUCT_BUNDLE_IDENTIFIER = com.allseeinginteractive.asihttprequest.tests; PRODUCT_NAME = Tests; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; + VALID_ARCHS = armv7; WARNING_CFLAGS = ""; }; name = Debug; @@ -904,6 +927,7 @@ baseConfigurationReference = B50F66181297FA45003887B1 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -915,19 +939,21 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iPhone Sample/iPhone_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ""; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "iPhone Sample/Tests-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; - IPHONEOS_DEPLOYMENT_TARGET = 3.2.2; LIBRARY_SEARCH_PATHS = ""; OTHER_LDFLAGS = ( "-ObjC", "-all_load", ); + PRODUCT_BUNDLE_IDENTIFIER = com.allseeinginteractive.asihttprequest.tests; PRODUCT_NAME = Tests; PROVISIONING_PROFILE = ""; SKIP_INSTALL = YES; + VALID_ARCHS = armv7; }; name = Release; }; @@ -936,17 +962,17 @@ baseConfigurationReference = B50F66181297FA45003887B1 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iPhone Sample/iPhone_Prefix.pch"; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "iPhone Sample/iPadInfo.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + PRODUCT_BUNDLE_IDENTIFIER = com.allseeinginteractive.asihttprequest.ipad.sample; PRODUCT_NAME = "ASIHTTPRequest iPad"; TARGETED_DEVICE_FAMILY = 2; }; @@ -957,14 +983,14 @@ baseConfigurationReference = B50F66181297FA45003887B1 /* strict.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; COPY_PHASE_STRIP = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iPhone Sample/iPhone_Prefix.pch"; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2"; INFOPLIST_FILE = "iPhone Sample/iPadInfo.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + PRODUCT_BUNDLE_IDENTIFIER = com.allseeinginteractive.asihttprequest.ipad.sample; PRODUCT_NAME = "ASIHTTPRequest iPad"; TARGETED_DEVICE_FAMILY = 2; }; @@ -973,11 +999,35 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -986,11 +1036,34 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; SDKROOT = iphoneos; }; name = Release;