MockURLProtocol
public final class MockURLProtocol : URLProtocol
Subclass of URLProtocol used to intercept requests
-
Errors that can be returned in the response via startLoading()
See moreDeclaration
Swift
public enum MockURLProtocolError : Swift.Error
-
If the request URL doesn’t exist as a key in the mocks dictionary, then MockURLProtocol won’t assert that it can handle the request
Declaration
Swift
public class func canHandle(url: URL) -> Bool
-
Will return true if canHandle(url:) returns true. Returns false if the task has no url.
Declaration
Swift
override public class func canInit(with task: URLSessionTask) -> Bool
-
Will return true if canHandle(url:) returns true. Returns false if the request has no url.
Declaration
Swift
override public class func canInit(with request: URLRequest) -> Bool
-
Returns the request unmodified.
Declaration
Swift
override public class func canonicalRequest(for request: URLRequest) -> URLRequest
-
Always returns false
Declaration
Swift
override public class func requestIsCacheEquivalent(_ a: URLRequest, to b: URLRequest) -> Bool
-
This method retrieves a mock and returns a response based on the configruation it contains.
Declaration
Swift
override public func startLoading()
-
This method does nothing as we aren’t initiating any network requests
Declaration
Swift
override public func stopLoading()