I have seen many questions that ask (and answer) how to provide credentials when you know in advance that the request requires them.
When I load a site that requests an authentication call (responds with HTTP 401), my UIWebViewDelegate receives only the following callbacks: webView:shouldStartLoadWithRequest:navigationType: and sometimes webViewDidStartLoad: ( webViewDidStartLoad: seems to be called if I go directly to the site, and doesn't seem to be called if I am redirected there).
Overriding -[NSObject respondsToSelector:] , the UIWebViewDelegate receives some calls to uiWebView:resource:canAuthenticateAgainstProtectionSpace:forDataSource: and uiWebView:resource:didReceiveAuthenticationChallenge:fromDataSource: which can be useful, of course, but of course.
I tested several different applications with built-in UIWebView s. So far, only Chrome has handled these authentication tasks properly. I even set up my own server and confirmed that Chrome only POST once. Twitter and Tweetbot just show the download screen forever, like mine.
Is there any other (possibly very hacky) way to detect these authentication problems besides using the second speculative NSURLConnection ? If I make a POST request that will be double- POST all that is bad.
I added a radar to request improvements for the UIWebView for this . Please duplicate it.
source share