Skip to content

Commit

Permalink
Update various tests and samples to use new API
Browse files Browse the repository at this point in the history
  • Loading branch information
pokeb committed Jan 4, 2010
1 parent df7f85e commit 65457df
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Classes/ASIHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#import "ASIInputStream.h"

// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.2-59 2010-01-04";
NSString *ASIHTTPRequestVersion = @"v1.2-60 2010-01-04";

NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";

Expand Down
8 changes: 4 additions & 4 deletions Classes/Tests/ASIHTTPRequestTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1152,28 +1152,28 @@ - (void)testAsynchronous
[request setDidFailSelector:@selector(asyncFail:)];
[request setDidFinishSelector:@selector(asyncSuccess:)];
[request setDelegate:self];
[request start];
[request startAsynchronous];

request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/second"]];
[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:2] forKey:@"RequestNumber"]];
[request setDidFailSelector:@selector(asyncFail:)];
[request setDidFinishSelector:@selector(asyncSuccess:)];
[request setDelegate:self];
[request start];
[request startAsynchronous];

request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/third"]];
[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:3] forKey:@"RequestNumber"]];
[request setDidFailSelector:@selector(asyncFail:)];
[request setDidFinishSelector:@selector(asyncSuccess:)];
[request setDelegate:self];
[request start];
[request startAsynchronous];

request = [ASIHTTPRequest requestWithURL:nil];
[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:4] forKey:@"RequestNumber"]];
[request setDidFailSelector:@selector(asyncFail:)];
[request setDidFinishSelector:@selector(asyncSuccess:)];
[request setDelegate:self];
[request start];
[request startAsynchronous];
}


Expand Down
6 changes: 3 additions & 3 deletions Classes/Tests/ASIS3RequestTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ - (void)testREST
[request setMimeType:@"text/plain"];
[request setSecretAccessKey:secretAccessKey];
[request setAccessKey:accessKey];
[request start];
[request startSynchronous];
success = [[request responseString] isEqualToString:@""];
GHAssertTrue(success,@"Failed to PUT data to S3");

// GET the data to check it uploaded properly
request = [ASIS3Request requestWithBucket:bucket path:path];
[request setSecretAccessKey:secretAccessKey];
[request setAccessKey:accessKey];
[request start];
[request startSynchronous];
success = [[request responseString] isEqualToString:@"Hello"];
GHAssertTrue(success,@"Failed to GET the correct data from S3");

Expand All @@ -244,7 +244,7 @@ - (void)testREST
[request setSecretAccessKey:secretAccessKey];
[request setRequestMethod:@"DELETE"];
[request setAccessKey:accessKey];
[request start];
[request startSynchronous];
success = [[request responseString] isEqualToString:@""];
GHAssertTrue(success,@"Failed to DELETE the file from S3");

Expand Down
16 changes: 8 additions & 8 deletions Classes/Tests/ProxyTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,36 @@ - (void)testAutoConfigureWithPAC
NSString *pacurl = @"file:///non-existent.pac";
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request setPACurl:[NSURL URLWithString:pacurl]];
[request start];
[request startSynchronous];
GHAssertNil([request proxyHost],@"Shouldn't use a proxy here");
GHAssertNil([request error],@"Request failed when unable to fetch PAC (should assume no proxy instead)");

// To run this test, specify the location of the pac script that is available at http://developer.apple.com/samplecode/CFProxySupportTool/listing1.html
pacurl = @"file:///Users/ben/Desktop/test.pac";
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request setPACurl:[NSURL URLWithString:pacurl]];
[request start];
[request startSynchronous];

BOOL success = [[request proxyHost] isEqualToString:@"proxy1.apple.com"];
GHAssertTrue(success,@"Failed to use the correct proxy");

request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]];
[request setPACurl:[NSURL URLWithString:pacurl]];
[request start];
[request startSynchronous];
GHAssertNil([request proxyHost],@"Used a proxy when the script told us to go direct");
}

- (void)testAutoConfigureWithSystemPAC
{
// To run this test, specify the pac script above in your network settings
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request start];
[request startSynchronous];

BOOL success = [[request proxyHost] isEqualToString:@"proxy1.apple.com"];
GHAssertTrue(success,@"Failed to use the correct proxy");

request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]];
[request start];
[request startSynchronous];
GHAssertNil([request proxyHost],@"Used a proxy when the script told us to go direct");
}

Expand All @@ -65,7 +65,7 @@ - (void)testProxy
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request setProxyHost:proxyHost];
[request setProxyPort:proxyPort];
[request start];
[request startSynchronous];

// Check data is as expected
NSRange notFound = NSMakeRange(NSNotFound, 0);
Expand All @@ -76,7 +76,7 @@ - (void)testProxy
- (void)testProxyAutodetect
{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]];
[request start];
[request startSynchronous];

BOOL success = ([request proxyHost] && [request proxyPort]);
GHAssertTrue(success,@"Failed to detect the proxy");
Expand All @@ -93,7 +93,7 @@ - (void)testProxyWithSuppliedAuthenticationCredentials
[request setProxyPort:proxyPort];
[request setProxyUsername:proxyUsername];
[request setProxyPassword:proxyPassword];
[request start];
[request startSynchronous];

// Check data is as expected
NSRange notFound = NSMakeRange(NSNotFound, 0);
Expand Down
6 changes: 3 additions & 3 deletions Classes/Tests/StressTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ - (void)performCancelRequest
[[self cancelRequest] setDownloadProgressDelegate:self];
[[self cancelRequest] setShowAccurateProgress:YES];
NSLog(@"Stress test: Start request %@",[self cancelRequest]);
[[self cancelRequest] start];
[[self cancelRequest] startAsynchronous];
}
}

Expand All @@ -105,7 +105,7 @@ - (void)performRedirectRequest
[self setCancelRequest:[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1/ASIHTTPRequest/tests/one_infinite_loop"]]];
if ([[self cancelStartDate] timeIntervalSinceNow] > 0) {
NSLog(@"Redirect stress test: Start request %@",[self cancelRequest]);
[[self cancelRequest] start];
[[self cancelRequest] startAsynchronous];
[self performSelector:@selector(cancelRedirectRequest) withObject:nil afterDelay:0.2];
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ - (void)performSetDelegateRequest
[[self cancelRequest] setDelegate:delegate];
[[self cancelRequest] setShowAccurateProgress:YES];
NSLog(@"Set delegate stress test: Start request %@",[self cancelRequest]);
[[self cancelRequest] start];
[[self cancelRequest] startAsynchronous];
[self performSelectorInBackground:@selector(cancelSetDelegateRequest) withObject:nil];
}
[createRequestLock unlock];
Expand Down
6 changes: 3 additions & 3 deletions Mac Sample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ - (IBAction)resumeURLFetchWithProgress:(id)sender
[[self bigFetchRequest] setAllowResumeForFileDownloads:YES];
[[self bigFetchRequest] setDidFinishSelector:@selector(URLFetchWithProgressComplete:)];
[[self bigFetchRequest] setDownloadProgressDelegate:progressIndicator];
[[self bigFetchRequest] start];
[[self bigFetchRequest] startAsynchronous];
}

- (void)URLFetchWithProgressComplete:(ASIHTTPRequest *)request
Expand Down Expand Up @@ -193,7 +193,7 @@ - (IBAction)fetchTopSecretInformation:(id)sender
//[request setShouldRunInBackgroundThread:YES];
[request setDelegate:self];
[request setUseKeychainPersistance:[keychainCheckbox state]];
[request start];
[request startAsynchronous];

}

Expand Down Expand Up @@ -237,7 +237,7 @@ - (IBAction)dismissAuthSheet:(id)sender {
- (void)authSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
ASIHTTPRequest *request = (ASIHTTPRequest *)contextInfo;
if (returnCode == NSOKButton) {
if ([request needsProxyAuthentication]) {
if ([request authenticationNeeded] == ASIProxyAuthenticationNeeded) {
[request setProxyUsername:[[[username stringValue] copy] autorelease]];
[request setProxyPassword:[[[password stringValue] copy] autorelease]];
} else {
Expand Down
4 changes: 2 additions & 2 deletions Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
Expand All @@ -556,7 +556,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
Expand Down
1 change: 0 additions & 1 deletion iPhone Sample/AuthenticationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ - (IBAction)fetchTopSecretInformation:(id)sender
[request setShouldPresentAuthenticationDialog:[useBuiltInDialog isOn]];
[request setDidFinishSelector:@selector(topSecretFetchComplete:)];
[request setDidFailSelector:@selector(topSecretFetchFailed:)];
[request setShouldRunInBackgroundThread:YES];
[request start];

}
Expand Down
3 changes: 3 additions & 0 deletions iPhone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -552,6 +553,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -582,6 +584,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "iPhone Sample/iPhone_Prefix.pch";
Expand Down

0 comments on commit 65457df

Please sign in to comment.