NSURLProtocolClient Protocol Reference
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.2 with Safari 1.0 installed. Available in OS X v10.2.7 and later. |
| Companion guide | |
| Declared in | NSURLProtocol.h |
Overview
The NSURLProtocolClient protocol provides the interface used by NSURLProtocol subclasses to communicate with the URL loading system. An application should never have the need to implement this protocol.
Tasks
Protocol Methods
-
– URLProtocol:cachedResponseIsValid:required method -
– URLProtocol:didCancelAuthenticationChallenge:required method -
– URLProtocol:didFailWithError:required method -
– URLProtocol:didLoadData:required method -
– URLProtocol:didReceiveAuthenticationChallenge:required method -
– URLProtocol:didReceiveResponse:cacheStoragePolicy:required method -
– URLProtocol:wasRedirectedToRequest:redirectResponse:required method -
– URLProtocolDidFinishLoading:required method
Instance Methods
URLProtocol:cachedResponseIsValid:
Sent to indicate to the URL loading system that a cached response is valid. (required)
Parameters
- protocol
The URL protocol object sending the message.
- cachedResponse
The cached response whose validity is being communicated.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocol:didCancelAuthenticationChallenge:
Sent to indicate to the URL loading system that an authentication challenge has been canceled. (required)
Parameters
- protocol
The URL protocol object sending the message.
- challenge
The authentication challenge that was canceled.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocol:didFailWithError:
Sent when the load request fails due to an error. (required)
Parameters
- protocol
The URL protocol object sending the message.
- error
The error that caused the failure of the load request.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocol:didLoadData:
An NSURLProtocol subclass instance, protocol, sends this message to [protocol client] as it loads data. (required)
Discussion
The data object must contain only new data loaded since the previous invocation of this method.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocol:didReceiveAuthenticationChallenge:
Sent to indicate to the URL loading system that an authentication challenge has been received. (required)
Parameters
- protocol
The URL protocol object sending the message.
- challenge
The authentication challenge that has been received.
Discussion
The protocol client guarantees that it will answer the request on the same thread that called this method. The client may add a default credential to the challenge it issues to the connection delegate, if protocol did not provide one.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocol:didReceiveResponse:cacheStoragePolicy:
Sent to indicate to the URL loading system that the protocol implementation has created a response object for the request. (required)
Parameters
- protocol
The URL protocol object sending the message.
- response
The newly available response object.
- policy
The cache storage policy for the response.
Discussion
The implementation should use the provided cache storage policy to determine whether to store the response in a cache.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocol:wasRedirectedToRequest:redirectResponse:
Sent to indicate to the URL loading system that the protocol implementation has been redirected. (required)
Parameters
- protocol
The URL protocol object sending the message.
- request
The new request that the original request was redirected to.
- redirectResponse
The response from the original request that caused the redirect.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.hURLProtocolDidFinishLoading:
Sent to indicate to the URL loading system that the protocol implementation has finished loading. (required)
Parameters
- protocol
The URL protocol object sending the message.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtocol.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-06-06)