FRURLProtocol
@objc
open class FRURLProtocol : URLProtocol
extension FRURLProtocol: URLSessionDataDelegate
-
TokenManagementPolicy for URLProtocol
Declaration
Swift
@objc public static var tokenManagementPolicy: TokenManagementPolicy?
-
AuthorizationPolicy for URLProtocol
Declaration
Swift
@objc public static var authorizationPolicy: AuthorizationPolicy?
-
FRSecurityConfiguration for URLProtocol - Used for SSL Pinning
Declaration
Swift
@objc public static var frSecurityConfiguration: FRSecurityConfiguration?
-
Returns a canonical version of the given request
Declaration
Swift
public override class func canonicalRequest(for request: URLRequest) -> URLRequest
Parameters
request
A request to make canonical
Return Value
The canonical form of the given request
-
Declaration
Swift
public override class func canInit(with request: URLRequest) -> Bool
-
Starts loading, and validating the request
Declaration
Swift
public override func startLoading()
-
Stops loading, and indicates that the request has finished
Declaration
Swift
public override func stopLoading()
-
URLSessionDataDelegate method for receiving data
Declaration
Swift
public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data)
Parameters
session
URLSession
dataTask
Current URLSessionDataTask
data
Data received
-
URLSessionDataDelegate method for receiving response
Declaration
Swift
public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void)
Parameters
session
URLSession
dataTask
Current URLSessionDataTask
response
Response received
completionHandler
Completion callback
-
URLSessionDataDelegate method to notify completion of the request
In this delegation method, FRURLProtocol will validate the result of the request with given ValidatedURLs, RefreshTokenPolicy, and maximum retry attempt, and perform token refresh if necessary
Declaration
Swift
public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)
Parameters
session
URLSession
task
Current URLSessionDataTask
error
An error occurred during the request
-
URLSessionDataDelegate method for HTTP Redirection
Declaration
Swift
public func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void)
Parameters
session
URLSession
task
Current URLSessionTask
response
HTTPURLResponse which may explain reason for redirection
request
Newly constructed URLRequest object
completionHandler
Completion callback
-
URLSessionDataDelegate method for invalidating the current request with an error
Declaration
Swift
public func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?)
Parameters
session
URLSession
error
An error occurred during the request
-
URLSessionDelegate method for Authentication Challenge
Declaration
Swift
public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
Parameters
session
URLSession
challenge
URLAuthenticationChallenge
completionHandler
Completion callback
-
URLSessionTaskDelegate method for Authentication Challenge
Declaration
Swift
public func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
Parameters
session
URLSession
task
URLSessionTask
challenge
URLAuthenticationChallenge
completionHandler
Completion callback
-
URLSessionDataDelegate method
Declaration
Swift
public func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession)
Parameters
session
URLSession