RequestInterceptor
public protocol RequestInterceptor : RequestAdapter, RequestRetrier
Type that provides both RequestAdapter and RequestRetrier functionality.
-
adapt(_:Extension methodfor: completion: ) Declaration
Swift
public func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result<URLRequest, Error>) -> Void) -
retry(_:Extension methodfor: dueTo: completion: ) Declaration
Swift
public func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void)
-
interceptor(adapter:Extension methodretrier: ) Creates an
Interceptorusing the providedAdaptHandlerandRetryHandlerclosures.Declaration
Swift
public static func interceptor(adapter: @escaping AdaptHandler, retrier: @escaping RetryHandler) -> InterceptorParameters
adapterAdapterHandlerto use to adapt the request.retrierRetryHandlerto use to retry the request.Return Value
The
Interceptor. -
interceptor(adapter:Extension methodretrier: ) Creates an
Interceptorusing the providedRequestAdapterandRequestRetrierinstances.Declaration
Swift
public static func interceptor(adapter: RequestAdapter, retrier: RequestRetrier) -> InterceptorParameters
adapterRequestAdapterto use to adapt the requestretrierRequestRetrierto use to retry the request.Return Value
The
Interceptor. -
interceptor(adapters:Extension methodretriers: interceptors: ) Creates an
Interceptorusing the providedRequestAdapters,RequestRetriers, andRequestInterceptors.Declaration
Swift
public static func interceptor(adapters: [RequestAdapter] = [], retriers: [RequestRetrier] = [], interceptors: [RequestInterceptor] = []) -> InterceptorParameters
adaptersRequestAdapters to use to adapt the request. These adapters will be run until one fails.retriersRequestRetriers to use to retry the request. These retriers will be run one at a time until a retry is triggered.interceptorsRequestInterceptors to use to intercept the request.Return Value
The
Interceptor.
-
retryPolicyExtension methodProvides a default
RetryPolicyinstance.Declaration
Swift
public static var retryPolicy: RetryPolicy { get } -
retryPolicy(retryLimit:Extension methodexponentialBackoffBase: exponentialBackoffScale: retryableHTTPMethods: retryableHTTPStatusCodes: retryableURLErrorCodes: ) Creates an
RetryPolicyfrom the specified parameters.Declaration
Swift
public static func retryPolicy(retryLimit: UInt = RetryPolicy.defaultRetryLimit, exponentialBackoffBase: UInt = RetryPolicy.defaultExponentialBackoffBase, exponentialBackoffScale: Double = RetryPolicy.defaultExponentialBackoffScale, retryableHTTPMethods: Set<HTTPMethod> = RetryPolicy.defaultRetryableHTTPMethods, retryableHTTPStatusCodes: Set<Int> = RetryPolicy.defaultRetryableHTTPStatusCodes, retryableURLErrorCodes: Set<URLError.Code> = RetryPolicy.defaultRetryableURLErrorCodes) -> RetryPolicyParameters
retryLimitThe total number of times the request is allowed to be retried.
2by default.exponentialBackoffBaseThe base of the exponential backoff policy.
2by default.exponentialBackoffScaleThe scale of the exponential backoff.
0.5by default.retryableHTTPMethodsThe HTTP methods that are allowed to be retried.
RetryPolicy.defaultRetryableHTTPMethodsby default.retryableHTTPStatusCodesThe HTTP status codes that are automatically retried by the policy.
RetryPolicy.defaultRetryableHTTPStatusCodesby default.retryableURLErrorCodesThe URL error codes that are automatically retried by the policy.
RetryPolicy.defaultRetryableURLErrorCodesby default.Return Value
The
RetryPolicy
-
connectionLostRetryPolicyExtension methodProvides a default
ConnectionLostRetryPolicyinstance.Declaration
Swift
public static var connectionLostRetryPolicy: ConnectionLostRetryPolicy { get } -
connectionLostRetryPolicy(retryLimit:Extension methodexponentialBackoffBase: exponentialBackoffScale: retryableHTTPMethods: ) Creates a
ConnectionLostRetryPolicyinstance from the specified parameters.Declaration
Swift
public static func connectionLostRetryPolicy(retryLimit: UInt = RetryPolicy.defaultRetryLimit, exponentialBackoffBase: UInt = RetryPolicy.defaultExponentialBackoffBase, exponentialBackoffScale: Double = RetryPolicy.defaultExponentialBackoffScale, retryableHTTPMethods: Set<HTTPMethod> = RetryPolicy.defaultRetryableHTTPMethods) -> ConnectionLostRetryPolicyParameters
retryLimitThe total number of times the request is allowed to be retried.
RetryPolicy.defaultRetryLimitby default.exponentialBackoffBaseThe base of the exponential backoff policy.
RetryPolicy.defaultExponentialBackoffBaseby default.exponentialBackoffScaleThe scale of the exponential backoff.
RetryPolicy.defaultExponentialBackoffScaleby default.retryableHTTPMethodsThe idempotent http methods to retry.
Return Value
View on GitHub
Install in Dash
RequestInterceptor Protocol Reference