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.

  • A set of errors that may be encountered at run-time when interacting with a recored HTTP interaction.

    See more

    Declaration

    Swift

    public enum Error
  • A type that indicates how the VCR instance should playback the recorded HTTP interactions from the loaded Cassette.

    See more

    Declaration

    Swift

    public enum PlaybackSequence
  • A type that indicates how many times the VCR instance should playback the recorded HTTP interactions from the loaded Cassette.

    See more

    Declaration

    Swift

    public enum ReplayCount
  • Create a VCR instance to playback recorded HTTP interactions from a Cassette.

    Parameter

    Parameter play: The Cassette containing the HTTP interactions to be played back.

    Parameter

    Parameter in: The OperationQueue to send the asynchronous results back on. Defaults to a new OperationQueue instance that can perform at most 1 operation at a time.

    Parameter

    Parameter match: The order in which to playback the Cassette. Defaults to the Cassette’s internal order.

    Parameter

    Parameter replay: The number of times to replay the HTTP interactions in the Cassette. Defaults to playing each Track 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 new OperationQueue instance that can perform at most 1 operation at a time.

    match

    The order in which to playback the Cassette. Defaults to the Cassette’s internal order.

    replay

    The number of times to replay the HTTP interactions in the Cassette. Defaults to playing each Track one time only.

    notify

    A delegate to notify of session level events. Default is no delegate.

  • 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