Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARC support and fix all warnings and errors for Xcode 9.1 and iOS 11.1 #412

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8109273
fixed bug that form data request can't add custom Content-Type to header
V01dZer0 Feb 16, 2013
269f36c
fixed 5 warnings using SDK7. fixed bug that input stream error never …
V01dZer0 Jul 9, 2013
b391060
fixed bug that https request can’t be send in iOS5
V01dZer0 Jul 9, 2013
5590066
ASIInputStream Support ARC
whlsxl Oct 10, 2013
0513a29
ASIDataDecompressor ARC
whlsxl Oct 12, 2013
dbdd651
ASIDataCompressor ARC
whlsxl Oct 12, 2013
1eb4f43
ASIHTTPRequest.h .m partial support ARC
whlsxl Oct 18, 2013
f4d7903
change + (void)updateProgressIndicator:(id*)indicator withProgress:(u…
whlsxl Oct 18, 2013
02a2bb3
Solve some ARC problem
whlsxl Oct 18, 2013
1e63d75
Solve PerformSelectorLeakWarning
whlsxl Oct 18, 2013
bfb37ac
Modify 2 properties
whlsxl Oct 18, 2013
87ce272
change + (void)performSelector:(SEL)selector onTarget:(id *)target wi…
whlsxl Oct 19, 2013
e0ed765
fix a memery leak
whlsxl Oct 20, 2013
1c606ed
fix a memery leak
whlsxl Oct 20, 2013
7d707ac
fix a warning
whlsxl Oct 20, 2013
a0c1383
update README
whlsxl Oct 20, 2013
21e579c
ASIFormDataRequest support ARC
whlsxl Oct 20, 2013
ac9e7ca
ASINetwrokQueue support ARC
whlsxl Oct 20, 2013
a882165
ASIAuthenticationDialog support ARC
whlsxl Oct 20, 2013
66c7291
change README
whlsxl Oct 20, 2013
8232e38
update Reachability to v3.1.1
whlsxl Oct 20, 2013
083f2ba
ASIDownloadCache and ASIWebPageRequest support ARC
whlsxl Oct 20, 2013
3fbad09
Fix test file warning
whlsxl Oct 20, 2013
94d2a03
Fix fake memery leak on test files
whlsxl Oct 20, 2013
94a7e16
Add some __bridge
whlsxl Oct 21, 2013
ea1d87d
ASIInputStream request change to weak
whlsxl Oct 21, 2013
882bef6
Fix some warning
whlsxl Oct 21, 2013
a0e88c8
1.Adjust format 2.add releaseBlocksOnMainThread when dealloc
whlsxl Oct 21, 2013
499a3be
fixed input stream leaks in iOS7
V01dZer0 Nov 13, 2013
73242f7
fixed input stream leaks in iOS7,fixed persistent connections error b…
Oct 24, 2017
f93711b
v2.0.0
Oct 24, 2017
1cd9b98
Merge branch 'master' of https://github.com/OpenFibers/asi-http-reque…
rivera-ernesto Nov 13, 2017
0eb48f0
Merge branch 'OpenFibers-master'
rivera-ernesto Nov 13, 2017
c0149e7
Merge branch 'master' of https://github.com/John1261/asi-http-request…
rivera-ernesto Nov 13, 2017
424f391
Merge branch 'John1261-master'
rivera-ernesto Nov 13, 2017
815570f
Merge branch 'master' of https://github.com/gbanfalvikl/asi-http-requ…
rivera-ernesto Nov 13, 2017
8982b70
Merge branch 'gbanfalvikl-master'
rivera-ernesto Nov 13, 2017
df38942
Fix assumed atomic warnings
rivera-ernesto Nov 13, 2017
2425e85
Fix implicit conversion warning
rivera-ernesto Nov 13, 2017
fd768af
Fix CFNetworkCopyProxiesForURL parameter warning
rivera-ernesto Nov 13, 2017
203011d
Remove deprecated SSL keys, use kCFStreamSSLValidatesCertificateChain…
rivera-ernesto Nov 13, 2017
7640ad7
Fix cast warning
rivera-ernesto Nov 13, 2017
816f347
Make ASIInputStream a proper NSInputStream
rivera-ernesto Nov 13, 2017
8f1a408
Update Sample projects
rivera-ernesto Nov 13, 2017
01414fd
Fix use localization macro Analyzer warning
rivera-ernesto Nov 13, 2017
f4129ff
Add missing super call
rivera-ernesto Nov 13, 2017
5ff0f92
Add podspec
rivera-ernesto Nov 14, 2017
94e2116
Update podspec
rivera-ernesto Nov 14, 2017
774bbd2
App Extensions support
rivera-ernesto Nov 14, 2017
1ad98c3
Fix cast warnings
rivera-ernesto Nov 14, 2017
864f3f9
Add platforms to podspec
rivera-ernesto Nov 14, 2017
86e2afe
Revert "fixed bug that https request can’t be send in iOS5"
rivera-ernesto Jan 17, 2018
db8e051
Fix deprecated warnings
rivera-ernesto Jan 17, 2018
14dbbf2
Merge branch 'master' of https://github.com/whlsxl/asi-http-request i…
rivera-ernesto Feb 22, 2018
6216b56
Fix build
rivera-ernesto Feb 22, 2018
54a8e0b
Merge branch 'whlsxl-master'
rivera-ernesto Feb 22, 2018
1ea5dfd
Update podspec, for now disable macOS
rivera-ernesto Feb 22, 2018
ea0b48c
Fix build warnings
rivera-ernesto Feb 22, 2018
7df0f5b
Update README
rivera-ernesto Feb 22, 2018
145eaf6
Update README.textile
rivera-ernesto Feb 22, 2018
c25e42e
Fix implicitly retained warnings
rivera-ernesto Jan 15, 2019
89820f5
Fix Analyzer warnings
rivera-ernesto Jan 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions ASIHTTPRequest.podspec
Original file line number Diff line number Diff line change
@@ -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' => '[email protected]' }
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
47 changes: 22 additions & 25 deletions Classes/ASIAuthenticationDialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ @implementation ASIAuthenticationDialog
+ (void)initialize
{
if (self == [ASIAuthenticationDialog class]) {
requestsNeedingAuthentication = [[NSMutableArray array] retain];
requestsNeedingAuthentication = [NSMutableArray array];
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -310,16 +307,16 @@ - (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];
CGRect f = [[self view] bounds];
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];
Expand Down Expand Up @@ -458,15 +455,15 @@ - (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

[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];
Expand All @@ -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];

Expand Down
38 changes: 19 additions & 19 deletions Classes/ASICacheDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
5 changes: 2 additions & 3 deletions Classes/ASIDataCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
#import <zlib.h>

@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
Expand Down
20 changes: 9 additions & 11 deletions Classes/ASIDataCompressor.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand Down Expand Up @@ -98,7 +97,7 @@ - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSErro
if (err) {
*err = [[self class] deflateErrorWithCode:status];
}
return NO;
return nil;
}
}

Expand All @@ -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]) {
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions Classes/ASIDataDecompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
#import <zlib.h>

@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;
Expand Down
Loading