I'm posting some data to a http authenticated url with ASIFormDataRequest.
When the authentication fails and the authentication dialog delegate is invoked the upload progress seems to still proceed fully.
So in these cases:
1) The user's credentials are not yet stored in the keychain 2) The user's credentials which are stored in the keychain fail authentication (expired etc.)
I see this behavior:
- I see the request come in to my server and the 401 denied error returned to the client
- The uploadFailed delegate is not called.
- Progress bar delegate slowly fills as the file appears to still be pushed out on the network connection. It completes in a time consistent with the amount of time to fully upload
- The built in authentication dialog modal appears
- User enters correct credentials
- Progress bar delegate resets
- Upload begins again - progress bar fills as post data is received on server
- Finished delegate method is called as expected.
- Everything has uploaded just fine with this second attempt
Here's where I setup my operation:
[self setRequest:[ASIFormDataRequest requestWithURL:uploadURL]];
[request setDelegate:self];
[request setDidFailSelector:@selector(uploadFailed:)];
[request setDidFinishSelector:@selector(uploadFinished:)];
[request setUseKeychainPersistence:TRUE];
[request setShouldPresentAuthenticationDialog:TRUE];
[request setShouldPresentCredentialsBeforeChallenge:TRUE];
[request setPostValue:captionTextField.text forKey:@"caption"];
[request setPostValue:[siteID stringValue] forKey:@"site_id"];
[request setFile:fileToUpload forKey:@"site_photo"];
[request setUploadProgressDelegate:progressView];
[request startAsynchronous];
I am thinking I need to issue a [request cancel] upon the authentication failing but I'm not sure where I should be doing this.
Is it expected behavior that the POST will still chug away even after the server has returned a 401?
Appreciate any guidance or pointers to existing questions that address this.