RequestInterceptor
public protocol RequestInterceptor : RequestAdapter, RequestRetrier
Type that provides both RequestAdapter and RequestRetrier functionality.
-
adapt(_:Extension methodfor: completion: ) Declaration
Swift
@preconcurrency public func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping @Sendable (Result<URLRequest, any Error>) -> Void) -
retry(_:Extension methodfor: dueTo: completion: ) Declaration
Swift
@preconcurrency public func retry(_ request: Request, for session: Session, dueTo error: any Error, completion: @escaping @Sendable (RetryResult) -> Void)
-
deflateCompressorExtension methodCreate a
DeflateRequestCompressorwith defaultduplicateHeaderBehaviorandshouldCompressBodyDatavalues.Declaration
Swift
public static var deflateCompressor: DeflateRequestCompressor { get } -
deflateCompressor(duplicateHeaderBehavior:Extension methodshouldCompressBodyData: ) Creates a
DeflateRequestCompressorwith the providedDuplicateHeaderBehaviorandshouldCompressBodyDataclosure.Declaration
Swift
public static func deflateCompressor( duplicateHeaderBehavior: DeflateRequestCompressor.DuplicateHeaderBehavior = .error, shouldCompressBodyData: @escaping @Sendable (_ bodyData: Data) -> Bool = { _ in true } ) -> DeflateRequestCompressorParameters
duplicateHeaderBehaviorDuplicateHeaderBehaviorto use.shouldCompressBodyDataClosure which determines whether the outgoing body data should be compressed.
trueby default.Return Value
-
interceptor(adapter:Extension methodretrier: ) Creates an
Interceptorusing the providedAdaptHandlerandRetryHandlerclosures.Declaration
Swift
@preconcurrency 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
@preconcurrency public static func interceptor(adapter: any RequestAdapter, retrier: any 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
@preconcurrency public static func interceptor(adapters: [any RequestAdapter] = [], retriers: [any RequestRetrier] = [], interceptors: [any 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