Skip to content

Commit

Permalink
Prevent synchronous requests from using delegate authentication or AS…
Browse files Browse the repository at this point in the history
…IAuthenticationDialog

Comment tweaks
  • Loading branch information
pokeb committed May 28, 2011
1 parent e76a845 commit 5385af5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Classes/ASIHTTPRequest.h
Expand Up @@ -229,6 +229,7 @@ typedef void (^ASIDataBlock)(NSData *data);
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
Expand Down Expand Up @@ -294,7 +295,7 @@ typedef void (^ASIDataBlock)(NSData *data);
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 resume], or simply cancel it
// 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:
Expand Down
31 changes: 23 additions & 8 deletions Classes/ASIHTTPRequest.m
Expand Up @@ -2611,21 +2611,29 @@ - (void)failAuthentication

- (BOOL)showProxyAuthenticationDialog
{
// Mac authentication dialog coming soon!
#if TARGET_OS_IPHONE
if ([self isSynchronous]) {
return NO;
}

// Mac authentication dialog coming soon!
#if TARGET_OS_IPHONE
if ([self shouldPresentProxyAuthenticationDialog]) {
[ASIAuthenticationDialog performSelectorOnMainThread:@selector(presentAuthenticationDialogForRequest:) withObject:self waitUntilDone:[NSThread isMainThread]];
return YES;
}
return NO;
#else
#else
return NO;
#endif
#endif
}


- (BOOL)willAskDelegateForProxyCredentials
{
if ([self isSynchronous]) {
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];
Expand Down Expand Up @@ -2673,6 +2681,10 @@ - (void)askDelegateForProxyCredentials

- (BOOL)willAskDelegateForCredentials
{
if ([self isSynchronous]) {
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];
Expand Down Expand Up @@ -2875,16 +2887,19 @@ - (void)attemptToApplyProxyCredentialsAndResume

- (BOOL)showAuthenticationDialog
{
// Mac authentication dialog coming soon!
#if TARGET_OS_IPHONE
if ([self isSynchronous]) {
return NO;
}
// Mac authentication dialog coming soon!
#if TARGET_OS_IPHONE
if ([self shouldPresentAuthenticationDialog]) {
[ASIAuthenticationDialog performSelectorOnMainThread:@selector(presentAuthenticationDialogForRequest:) withObject:self waitUntilDone:[NSThread isMainThread]];
return YES;
}
return NO;
#else
#else
return NO;
#endif
#endif
}

- (void)attemptToApplyCredentialsAndResume
Expand Down

0 comments on commit 5385af5

Please sign in to comment.