VCR
public final class VCR: URLSession
A VCR
instance is used to replay HTTP interactions from a predefined fixture. Often the
recorded interactions are provided as a collection contained in a Cassette
instance.
The class extends URLSession
.
See also
Using NSURLSessionSee also
About the URL Loading System-
A set of errors that may be encountered at run-time when interacting with a recored HTTP interaction.
See moreDeclaration
Swift
public enum Error
-
Create a
VCR
instance to playback recorded HTTP interactions from aCassette
.Parameter
Parameter play: TheCassette
containing the HTTP interactions to be played back.Parameter
Parameter in: TheOperationQueue
to send the asynchronous results back on. Defaults to a newOperationQueue
instance that can perform at most 1 operation at a time.Parameter
Parameter match: The order in which to playback theCassette
. Defaults to theCassette
’s internal order.Parameter
Parameter replay: The number of times to replay the HTTP interactions in theCassette
. Defaults to playing eachTrack
one time only.Parameter
Parameter notify: A delegate to notify of session level events. Default is no delegate.Declaration
Swift
public init( play cassette: Cassette, in queue: OperationQueue? = .none, match sequenceType: PlaybackSequence = .cassetteOrder, replay duration: ReplayCount = .none, notify delegate: URLSessionDelegate? = .none )
Parameters
play
The
Cassette
containing the HTTP interactions to be played back.in
The
OperationQueue
to send the asynchronous results back on. Defaults to a newOperationQueue
instance that can perform at most 1 operation at a time.match
The order in which to playback the
Cassette
. Defaults to theCassette
’s internal order.replay
The number of times to replay the HTTP interactions in the
Cassette
. Defaults to playing eachTrack
one time only.notify
A delegate to notify of session level events. Default is no delegate.
-
The delegate assigned when this object was created.
Remark
This property is required by the base class.
Note
This delegate object must be set at object creation time and may not be changed. This requirement comes from the base class
NSURLSession
.Declaration
Swift
override public var delegate: URLSessionDelegate?
-
Creates a task that retrieves the contents of the specified URL.
Remark
This property is required by the base class.
Declaration
Swift
public override func dataTask(with url: URL) -> URLSessionDataTask
-
Creates a task that retrieves the contents of the specified URL, then calls a handler upon completion. The task bypasses calls to delegate methods for response and data delivery, and instead provides any resulting NSData, URLResponse, and NSError objects inside the completion handler. Delegate methods for handling authentication challenges, however, are still called.
Remark
This property is required by the base class.
Declaration
Swift
public override func dataTask(with request: URLRequest) -> URLSessionDataTask
-
Creates a task that retrieves the contents of a URL based on the specified URL request object.
Remark
This property is required by the base class.
Declaration
Swift
public override func dataTask( with url: URL, completionHandler: (Data?, URLResponse?, NSError?) -> Void ) -> URLSessionDataTask
-
Creates a task that retrieves the contents of a URL based on the specified URL request object, and calls a handler upon completion. The task bypasses calls to delegate methods for response and data delivery, and instead provides any resulting NSData, URLResponse, and NSError objects inside the completion handler. Delegate methods for handling authentication challenges, however, are still called.
Remark
This property is required by the base class.
Declaration
Swift
public override func dataTask( with request: URLRequest, completionHandler: (Data?, URLResponse?, NSError?) -> Void ) -> URLSessionDataTask