Next Page > Hide TOC

NSURLProtocolClient Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.2 with Safari 1.0 installed.
Available in Mac 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

Instance Methods

URLProtocol:cachedResponseIsValid:

Sent to indicate to the URL loading system that a cached response is valid.

- (void)URLProtocol:(NSURLProtocol *)protocol cachedResponseIsValid:(NSCachedURLResponse *)cachedResponse

Parameters
protocol

The URL protocol object sending the message.

cachedResponse

The cached response whose validity is being communicated.

Availability
Declared In
NSURLProtocol.h

URLProtocol:didCancelAuthenticationChallenge:

Sent to indicate to the URL loading system that an authentication challenge has been canceled.

- (void)URLProtocol:(NSURLProtocol *)protocol didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

Parameters
protocol

The URL protocol object sending the message.

challenge

The authentication challenge that was canceled.

Availability
Declared In
NSURLProtocol.h

URLProtocol:didFailWithError:

Sent when the load request fails due to an error.

- (void)URLProtocol:(NSURLProtocol *)protocol didFailWithError:(NSError *)error

Parameters
protocol

The URL protocol object sending the message.

error

The error that caused the failure of the load request.

Availability
Declared In
NSURLProtocol.h

URLProtocol:didLoadData:

An NSURLProtocol subclass instance, protocol, sends this message to [protocol client] as it loads data.

- (void)URLProtocol:(NSURLProtocol *)protocol didLoadData:(NSData *)data

Discussion

The data object must contain only new data loaded since the previous invocation of this method.

Availability
Declared In
NSURLProtocol.h

URLProtocol:didReceiveAuthenticationChallenge:

Sent to indicate to the URL loading system that an authentication challenge has been received.

- (void)URLProtocol:(NSURLProtocol *)protocol didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

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
Declared In
NSURLProtocol.h

URLProtocol:didReceiveResponse:cacheStoragePolicy:

Sent to indicate to the URL loading system that the protocol implementation has created a response object for the request.

- (void)URLProtocol:(NSURLProtocol *)protocol didReceiveResponse:(NSURLResponse *)response cacheStoragePolicy:(NSURLCacheStoragePolicy)policy

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 provide the NSURLCacheStoragePolicy that should be used if the response is to be stored in a cache as the policy value.

Availability
Declared In
NSURLProtocol.h

URLProtocol:wasRedirectedToRequest:redirectResponse:

Sent to indicate to the URL loading system that the protocol implementation has been redirected.

- (void)URLProtocol:(NSURLProtocol *)protocol wasRedirectedToRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse

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
Declared In
NSURLProtocol.h

URLProtocolDidFinishLoading:

Sent to indicate to the URL loading system that the protocol implementation has finished loading.

- (void)URLProtocolDidFinishLoading:(NSURLProtocol *)protocol

Parameters
protocol

The URL protocol object sending the message.

Availability
Declared In
NSURLProtocol.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.