Skip to content

Commit

Permalink
Retain queue
Browse files Browse the repository at this point in the history
Tweak tests
  • Loading branch information
pokeb committed Jul 27, 2010
1 parent 1da8a86 commit af1aaa6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Classes/ASIHTTPRequest.h
Expand Up @@ -78,6 +78,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;

// 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 <ASIHTTPRequestDelegate, ASIProgressDelegate> queue;

// HTTP method to use (GET / POST / PUT / DELETE / HEAD). Defaults to GET
Expand Down Expand Up @@ -766,7 +767,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
@property (retain,setter=setURL:) NSURL *url;
@property (retain) NSURL *originalURL;
@property (assign, nonatomic) id delegate;
@property (assign, nonatomic) id queue;
@property (retain, nonatomic) id queue;
@property (assign, nonatomic) id uploadProgressDelegate;
@property (assign, nonatomic) id downloadProgressDelegate;
@property (assign) BOOL useKeychainPersistence;
Expand Down
8 changes: 6 additions & 2 deletions Classes/ASIHTTPRequest.m
Expand Up @@ -23,7 +23,7 @@


// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.7-34 2010-07-27";
NSString *ASIHTTPRequestVersion = @"v1.7-35 2010-07-27";

NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";

Expand Down Expand Up @@ -317,6 +317,7 @@ - (void)dealloc
CFRelease(request);
}
[self cancelLoad];
[queue release];
[userInfo release];
[postBody release];
[compressedPostBody release];
Expand Down Expand Up @@ -502,7 +503,10 @@ - (id)queue
- (void)setQueue:(id)newQueue
{
[[self cancelledLock] lock];
queue = newQueue;
if (newQueue != queue) {
[queue release];
queue = [newQueue retain];
}
[[self cancelledLock] unlock];
}

Expand Down
21 changes: 13 additions & 8 deletions Classes/Tests/ASINetworkQueueTests.m
Expand Up @@ -54,6 +54,11 @@ - (void)testDelegateAuthenticationCredentialsReuse


- (void)testDelegateMethods
{
[self performSelectorOnMainThread:@selector(runDelegateMethodsTest) withObject:nil waitUntilDone:YES];
}

- (void)runDelegateMethodsTest
{
started = NO;
finished = NO;
Expand Down Expand Up @@ -436,8 +441,6 @@ - (void)testFailure
success = ([request5 responseStatusCode] == 404);
GHAssertTrue(success,@"Failed to obtain the correct status code for request 5");



[requestThatShouldFail release];

}
Expand Down Expand Up @@ -616,10 +619,6 @@ - (void)authenticationNeededForRequest:(ASIHTTPRequest *)request
}
}





- (void)requestFailedExpectedly:(ASIHTTPRequest *)request
{
request_didfail = YES;
Expand Down Expand Up @@ -677,7 +676,8 @@ - (void)testPartialResume
}

NSURL *downloadURL = [NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel_%28young_readers_edition%29.txt"];
ASINetworkQueue *networkQueue = [ASINetworkQueue queue];
ASINetworkQueue *networkQueue = [ASINetworkQueue queue];
[networkQueue setShouldCancelAllRequestsOnFailure:NO];

ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:downloadURL] autorelease];
[request setDownloadDestinationPath:downloadPath];
Expand Down Expand Up @@ -1084,8 +1084,13 @@ - (void)ntlmDone:(ASIHTTPRequest *)request
GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[[request responseString] lowercaseString]);
}

// Test for a bug where failing head requests would not notify the original request's delegate of the failure
- (void)testHEADFailure
{
[self performSelectorOnMainThread:@selector(runHEADFailureTest) withObject:nil waitUntilDone:YES];
}

// Test for a bug where failing head requests would not notify the original request's delegate of the failure
- (void)runHEADFailureTest
{
headFailed = NO;
ASINetworkQueue *queue = [ASINetworkQueue queue];
Expand Down

0 comments on commit af1aaa6

Please sign in to comment.