Protocol

URLProtocolClient

The interface used by URLProtocol subclasses to communicate with the URL Loading System.

Overview

Don’t implement this protocol in your application. Instead, your URLProtocol subclass calls methods of this protocol on its own client property.

Topics

Creating a Response

func urlProtocol(URLProtocol, didReceive: URLResponse, cacheStoragePolicy: URLCache.StoragePolicy)

Tells the client that the protocol implementation has created a response object for the request.

Required.

Handling Redirects

func urlProtocol(URLProtocol, wasRedirectedTo: URLRequest, redirectResponse: URLResponse)

Tells the client that the protocol implementation has been redirected.

Required.

Working with Cache Data

func urlProtocol(URLProtocol, cachedResponseIsValid: CachedURLResponse)

Tells the client that a cached response is valid.

Required.

Handling Authentication Challenges

func urlProtocol(URLProtocol, didCancel: URLAuthenticationChallenge)

Tells the client that an authentication challenge has been canceled.

Required.

func urlProtocol(URLProtocol, didReceive: URLAuthenticationChallenge)

Tells the client that the URL Loading System received an authentication challenge.

Required.

Indicating Loading Progress or Failure

func urlProtocol(URLProtocol, didFailWithError: Error)

Tells the client that the load request failed due to an error.

Required.

func urlProtocol(URLProtocol, didLoad: Data)

Tells the client that the protocol implementation has loaded some data.

Required.

func urlProtocolDidFinishLoading(URLProtocol)

Tells the client that the protocol implementation has finished loading.

Required.

Relationships

Inherits From

See Also

Getting Protocol Attributes

var cachedResponse: CachedURLResponse?

The protocol’s cached response.

var client: URLProtocolClient?

The object the protocol uses to communicate with the URL loading system.

var request: URLRequest

The protocol’s request.

var task: URLSessionTask?

The protocol’s task.