Re: Using NSURLProtectionSpace for undocumented/unusual spaces
Re: Using NSURLProtectionSpace for undocumented/unusual spaces
- Subject: Re: Using NSURLProtectionSpace for undocumented/unusual spaces
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Tue, 24 Mar 2015 09:57:13 +0000
On 23 Mar 2015, at 17:43, Daniel Jalkut <email@hidden> wrote:
> To that end, I’m curious about customizing NSURLProtectionSpace such that I would issue my own authentication challenges (mimicking the URL loading system’s automatic issuance of challenges).
I wouldn't go down this path. Rather, I'd wrap the built-in authentication challenge type with your own type and allow that type to specify your custom protection space if necessary. That way you can still have a single code path in your app, but you don't have to make any assumptions as to how well the system will handle unusual protection spaces.
My specific concern here relates to the interaction between the Foundation-level API classes you see and the CFNetwork level C++ classes that do all the heavy lifting here. My experience is that these interactions are not smooth [1]. For example, prior to the introduction of -[NSHTTPURLResponse initWithURL:statusCode:HTTPVersion:headerFields:], some folks tried constructing an NSHTTPURLResponse with their own status code and headers by subclassing NSHTTPURLResponse and overriding the -statusCode and -headerFields methods. This does not work because NSHTTPURLResponse is an Objective-C wrapper around a CFNetwork object, and overriding these Objective-C methods has no impact on CFNetwork-level callers.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
[1] Back in the day, when NSURLConnection was first released, its core implementation was in Objective-C and all this stuff worked a lot more smoothly.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden