Sun 07 Dec 2014 11:13:27 AM UTC, original submission:
If you run under a debugger the tool 'test06' (from the attached patch)
with a breakpoint on the line NSURLConnection.m:267 then you will get
the following frame:
----------------------------------------------------
Breakpoint 1, -[NSObject(NSURLConnectionDelegate) connection:didReceiveAuthenticationChallenge:] (self=0x7367b0,
_cmd=0x7ffff7d8b9f0 <_OBJC_SELECTOR_TABLE+688>, connection=0x737220, challenge=0x7f38f0) at NSURLConnection.m:267
(gdb) l
262 }
263
264 - (void) connection: (NSURLConnection *)connection
265 didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge
266 {
267 [[challenge sender]
268 continueWithoutCredentialForAuthenticationChallenge: challenge];
269 }
270
271 - (void) connection: (NSURLConnection *)connection
----------------------------------------------------
In this method the code logic commands to continue without a credential.
It doesn't make a check on whether there is a proposed credential or
the failure count. However if you climb up 2 frames then you will get to:
----------------------------------------------------
#2 0x00007ffff7908bda in -[_NSHTTPURLProtocol _got:] (self=0x780bb0, _cmd=0x7ffff7d92720 <_OBJC_SELECTOR_TABLE+2144>,
stream=0x783ad0) at NSURLProtocol.m:1163
----------------------------------------------------
then there before entering into:
----------------------------------------------------
[this->client URLProtocol: self
=> didReceiveAuthenticationChallenge: _challenge];
----------------------------------------------------
is the code chunk which makes a proposed credential from the request's URL:
----------------------------------------------------
_credential = [[NSURLCredential alloc]
initWithUser: [url user]
password: [url password]
persistence: NSURLCredentialPersistenceForSession];
....
....
_challenge = [[NSURLAuthenticationChallenge alloc]
initWithProtectionSpace: space
proposedCredential: _credential
previousFailureCount: failures
failureResponse: _response
error: nil
sender: self];
----------------------------------------------------
So currently if the library user provides a valid credential in the URL (e.g.
"http://login:password@localhost:54321") it wouldn't be used. Synchronous
requests to such a URL will fail.
The attached patch's summary:
* Source/NSURLConnection.m:
- fixed a bug... NSURLConnection couldn't make synchronous load
using URL's credential;
* Tests/base/NSURLConnection/test06.m:
- added a new test on synchronous load with authentication by
URL's credential;
* Tests/base/NSURLConnection/Helpers/RequestHandler.m:
- fixed a bug.... the Handler200 didn't supply a valid status line;
|