Re: How should a NSURLProtocol handle a wrong URL?
Re: How should a NSURLProtocol handle a wrong URL?
- Subject: Re: How should a NSURLProtocol handle a wrong URL?
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Mon, 04 Aug 2014 10:04:49 +0100
On 2 Aug 2014, at 00:17, Daryle Walker <email@hidden> wrote:
> Why would the goal matter when dealing with URLs that are so malformed that they shouldn’t be passed to the next step in the process.
Because it's likely to cause compatibility problems if your definition of "malformed" is different from someone else's definition. The last thing you want to do is fail a request that some other protocol could handle properly. This is especially problematic if the other protocol's implementation can change over time (for example, any of the built-in protocols).
My experience with NSURLProtocols is that lots of really weird URLs end up being passed to +canInitWithRequest: method. You should be particularly tolerant there, returning NO instead of crashing or tripping an assert.
Beyond that, if you're working on a custom scheme, rather than overriding a built-in scheme, I'd deal with malformed URLs by failing the request with NSURLErrorBadURL.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
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