Ben Copsey

Fix assertion failure when failing authentication using credentials supplied by …

…an asiauthenticationdialog
Tweak authentication sample to ensure response text field is loaded in advance - this ensures the response always shows up
... ... @@ -10,7 +10,7 @@
#import "ASIHTTPRequest.h"
#import <CoreGraphics/CoreGraphics.h>
ASIAuthenticationDialog *sharedDialog = nil;
static ASIAuthenticationDialog *sharedDialog = nil;
BOOL isDismissing = NO;
static NSMutableArray *requestsNeedingAuthentication = nil;
... ... @@ -200,8 +200,15 @@ static const NSUInteger kDomainSection = 1;
+ (void)dismiss
{
[[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated
{
[self retain];
[sharedDialog release];
sharedDialog = nil;
[self presentNextDialog];
[self release];
}
- (void)dismiss
... ... @@ -297,7 +304,6 @@ static const NSUInteger kDomainSection = 1;
[requestsNeedingAuthentication removeObject:theRequest];
}
[self dismiss];
[self performSelector:@selector(presentNextDialog) withObject:nil afterDelay:1];
}
- (NSArray *)requestsRequiringTheseCredentials
... ... @@ -356,7 +362,6 @@ static const NSUInteger kDomainSection = 1;
[theRequest retryUsingSuppliedCredentials];
[requestsNeedingAuthentication removeObject:theRequest];
}
[self performSelector:@selector(presentNextDialog) withObject:nil afterDelay:1];
[self dismiss];
}
... ...
... ... @@ -24,7 +24,7 @@
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.7-2 2010-06-30";
NSString *ASIHTTPRequestVersion = @"v1.7-3 2010-06-30";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ...
... ... @@ -96,6 +96,7 @@
{
[request cancel];
[request release];
[responseField release];
[super dealloc];
}
... ... @@ -106,6 +107,10 @@
- (void)viewDidLoad
{
[[[self navigationBar] topItem] setTitle:@"HTTP Authentication"];
responseField = [[UITextView alloc] initWithFrame:CGRectZero];
[responseField setBackgroundColor:[UIColor clearColor]];
[responseField setEditable:NO];
[responseField setText:@"Secret information will appear here if authentication succeeds"];
}
static NSString *intro = @"Demonstrates fetching content from an area that requires HTTP authentication. You will be prompted for a username and password, enter 'topsecret' for both.\nIf you turn on keychain support, successful authentication will result in the username and password you provided being stored in your keychain. The application will use these details rather than prompt you the next time.\nToggle 'Use built-in dialog' to switch between ASIHTTPRequest's built-in dialog, and one created by the delegate.";
... ... @@ -171,9 +176,7 @@ static NSString *intro = @"Demonstrates fetching content from an area that requi
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"] autorelease];
responseField = [[[UITextView alloc] initWithFrame:CGRectZero] autorelease];
[responseField setBackgroundColor:[UIColor clearColor]];
[responseField setText:@"Secret information will appear here if authentication succeeds"];
[[cell contentView] addSubview:responseField];
}
[responseField setFrame:CGRectMake(5,5,tableWidth-tablePadding,150)];
... ...
... ... @@ -60,6 +60,7 @@
[request cancel];
[request release];
[progressIndicator release];
[resultView release];
[super dealloc];
}
... ... @@ -70,6 +71,9 @@
- (void)viewDidLoad
{
[[[self navigationBar] topItem] setTitle:@"Tracking Upload Progress"];
resultView = [[UITextView alloc] initWithFrame:CGRectZero];
[resultView setBackgroundColor:[UIColor clearColor]];
progressIndicator = [[UIProgressView alloc] initWithFrame:CGRectZero];
}
static NSString *intro = @"Demonstrates POSTing content to a URL, showing upload progress.\nYou'll only see accurate progress for uploads when the request body is larger than 128KB (in 2.2.1 SDK), or when the request body is larger than 32KB (in 3.0 SDK)";
... ... @@ -91,12 +95,7 @@ static NSString *intro = @"Demonstrates POSTing content to a URL, showing upload
[goButton addTarget:self action:@selector(performLargeUpload:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:goButton];
if (!progressIndicator) {
progressIndicator = [[UIProgressView alloc] initWithFrame:CGRectMake((tablePadding/2)-10,20,200,10)];
} else {
[progressIndicator setFrame:CGRectMake((tablePadding/2)-10,20,200,10)];
}
[progressIndicator setFrame:CGRectMake((tablePadding/2)-10,20,200,10)];
[view addSubview:progressIndicator];
return view;
... ... @@ -128,9 +127,6 @@ static NSString *intro = @"Demonstrates POSTing content to a URL, showing upload
cell = [tableView dequeueReusableCellWithIdentifier:@"Response"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Response"] autorelease];
resultView = [[[UITextView alloc] initWithFrame:CGRectZero] autorelease];
[resultView setBackgroundColor:[UIColor clearColor]];
[[cell contentView] addSubview:resultView];
}
[resultView setFrame:CGRectMake(5,5,tableWidth-tablePadding,60)];
... ...