Ben Copsey

Fix stress test

... ... @@ -365,6 +365,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
// Run a request asynchronously in the current thread
- (void)startAsynchronous;
- (void)startInBackgroundThread;
#pragma mark request logic
... ...
... ... @@ -444,6 +444,12 @@ static BOOL isiPhoneOS2;
[self setInProgress:NO];
}
- (void)startInBackgroundThread
{
runningInOwnThread = YES;
[self performSelectorInBackground:@selector(startAsynchronous) withObject:nil];
}
- (void)start
{
... ... @@ -1741,8 +1747,7 @@ static BOOL isiPhoneOS2;
{
// Mac authentication dialog coming soon!
#if TARGET_OS_IPHONE
// Cannot show the dialog when we are running on the main thread, as the locks will cause the app to hang
if ([self shouldPresentProxyAuthenticationDialog] && ![NSThread isMainThread]) {
if ([self shouldPresentProxyAuthenticationDialog]) {
[ASIAuthenticationDialog performSelectorOnMainThread:@selector(presentProxyAuthenticationDialogForRequest:) withObject:self waitUntilDone:[NSThread isMainThread]];
return YES;
}
... ... @@ -1755,11 +1760,7 @@ static BOOL isiPhoneOS2;
- (BOOL)askDelegateForProxyCredentials
{
// Can't use delegate authentication when running on the main thread
if ([NSThread isMainThread]) {
return NO;
}
// If we have a delegate, we'll see if it can handle proxyAuthenticationNeededForRequest:.
// Otherwise, we'll try the queue (if this request is part of one) and it will pass the message on to its own delegate
id authenticationDelegate = [self delegate];
... ... @@ -1933,7 +1934,6 @@ static BOOL isiPhoneOS2;
{
// Mac authentication dialog coming soon!
#if TARGET_OS_IPHONE
// Cannot show the dialog when we are running on the main thread, as the locks will cause the app to hang
if ([self shouldPresentAuthenticationDialog]) {
[ASIAuthenticationDialog performSelectorOnMainThread:@selector(presentAuthenticationDialogForRequest:) withObject:self waitUntilDone:[NSThread isMainThread]];
return YES;
... ...
... ... @@ -35,6 +35,8 @@
- (void)testSetDelegate;
- (void)performSetDelegateRequest;
- (void)setProgress:(float)newProgress;
@property (retain) ASIHTTPRequest *cancelRequest;
@property (retain) NSDate *cancelStartDate;
@property (retain) MyDelegate *delegate;
... ...
... ... @@ -52,7 +52,7 @@ IMPORTANT
[[self cancelRequest] setDownloadProgressDelegate:self];
[[self cancelRequest] setShowAccurateProgress:YES];
NSLog(@"Stress test: Start request %@",[self cancelRequest]);
[[self cancelRequest] start];
[[self cancelRequest] startInBackgroundThread];
}
}
... ... @@ -76,7 +76,7 @@ IMPORTANT
[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] startInBackgroundThread];
[self performSelector:@selector(cancelRedirectRequest) withObject:nil afterDelay:0.2];
}
[createRequestLock unlock];
... ... @@ -113,7 +113,7 @@ IMPORTANT
[[self cancelRequest] setDelegate:delegate];
[[self cancelRequest] setShowAccurateProgress:YES];
NSLog(@"Set delegate stress test: Start request %@",[self cancelRequest]);
[[self cancelRequest] start];
[[self cancelRequest] startInBackgroundThread];
[self performSelectorInBackground:@selector(cancelSetDelegateRequest) withObject:nil];
}
[createRequestLock unlock];
... ... @@ -127,7 +127,12 @@ IMPORTANT
}
- (void)setProgress:(float)newProgress;
- (void)setDoubleValue:(double)newProgress
{
[self setProgress:(float)newProgress];
}
- (void)setProgress:(float)newProgress
{
progress = newProgress;
... ...