[
https://issues.apache.org/jira/browse/CB-2415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13634202#comment-13634202
]
Zach White commented on CB-2415:
--------------------------------
h3.Here is the issue description as I have come to understand it:
In an effort to give each application it's own unique feel, Apple did not
implement a Basic Authorization popup in their UIWebView. Instead they provided
delegate methods (such as didReceiveAuthenticationChallenge for
NSURLConnection) for their connection classes so that each application could
handle the auth challenge in their own way (as far as prompting the user and
such). Since Cordova allows all web requests coming from UIWebView to pass
through to the default loading system, and no implementation is given by
Cordova to handle an auth challenge; when an auth challenge is given by the
server, Cordova (at the JS level) is oblivious and thus the $.ajax or XHR
request appears to hang.
h3.Here is the solution that I would propose
The solution that I found was to have Cordova handle all of the http(s)
requests. I created a class CDVURLConnection to handle connection and
delegation of these requests. If an auth challenge is received, it will give
the 401 back to the loading system (and thus the JS layer) and then the Cordova
developer can decide what to do from there.
I have updated [the project found
here|https://github.com/whit1440/CordovaAjaxTest] with the solution I propose
to this issue.
If handling all http(s) requests seems to scary (though it's working fine for
me for everything I've thrown at it), perhaps a flag could be added to the
config.xml saying whether your app will use requests with Basic Auth and thus
will need this functionality or not.
Thanks
PS Again please note that this is +only an iOS issue+.
> On iOS the ajax error/fail callback is not called after server returns error
> code 401/unauthorized
> --------------------------------------------------------------------------------------------------
>
> Key: CB-2415
> URL: https://issues.apache.org/jira/browse/CB-2415
> Project: Apache Cordova
> Issue Type: Bug
> Components: iOS
> Affects Versions: 2.2.0
> Environment: OSX 10.8.2, Xcode 4.5.1, iOS Simulator 5.0, 5.1, 6.0,
> cordova 2.2
> Reporter: Zach White
> Assignee: Shazron Abdullah
> Labels: 401, BasicAuth, iOS
>
> I am seeing the same issue as reported in
> [CB-2284|https://issues.apache.org/jira/browse/CB-2284] also in iOS. Ajax
> calls with Authorization header set are not returning but are timing out when
> the authorization credentials are invalid.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira