-
Notifications
You must be signed in to change notification settings - Fork 1
Request
Request
is the common superclass of all Alamofire request types and provides common state, delegate, and callback
handling.
public class Request
CustomStringConvertible
, Equatable
, Hashable
Closure type executed when monitoring the upload or download progress of a request.
public typealias ProgressHandler = (Progress) -> Void
Used to represent whether a validation succeeded or failed.
public typealias ValidationResult = Result<Void, Error>
Posted when a Request
is resumed. The Notification
contains the resumed Request
.
let didResumeNotification
Posted when a Request
is suspended. The Notification
contains the suspended Request
.
let didSuspendNotification
Posted when a Request
is cancelled. The Notification
contains the cancelled Request
.
let didCancelNotification
Posted when a Request
is finished. The Notification
contains the completed Request
.
let didFinishNotification
Posted when a URLSessionTask
is resumed. The Notification
contains the Request
associated with the URLSessionTask
.
let didResumeTaskNotification
Posted when a URLSessionTask
is suspended. The Notification
contains the Request
associated with the URLSessionTask
.
let didSuspendTaskNotification
Posted when a URLSessionTask
is cancelled. The Notification
contains the Request
associated with the URLSessionTask
.
let didCancelTaskNotification
Posted when a URLSessionTask
is completed. The Notification
contains the Request
associated with the URLSessionTask
.
let didCompleteTaskNotification
UUID
providing a unique identifier for the Request
, used in the Hashable
and Equatable
conformances.
let id: UUID
The serial queue for all internal async actions.
let underlyingQueue: DispatchQueue
The queue used for all serialization actions. By default it's a serial queue that targets underlyingQueue
.
let serializationQueue: DispatchQueue
EventMonitor
used for event callbacks.
let eventMonitor: EventMonitor?
The Request
's interceptor.
let interceptor: RequestInterceptor?
The Request
's delegate.
var delegate: RequestDelegate?
State
of the Request
.
var state: State
Returns whether state
is .initialized
.
var isInitialized: Bool
Returns whether state is
.resumed`.
var isResumed: Bool
Returns whether state
is .suspended
.
var isSuspended: Bool
Returns whether state
is .cancelled
.
var isCancelled: Bool
Returns whether state
is .finished
.
var isFinished: Bool
Progress
of the upload of the body of the executed URLRequest
. Reset to 0
if the Request
is retried.
let uploadProgress
Progress
of the download of any response data. Reset to 0
if the Request
is retried.
let downloadProgress
RedirectHandler
set on the instance.
var redirectHandler: RedirectHandler?
CachedResponseHandler
set on the instance.
var cachedResponseHandler: CachedResponseHandler?
URLCredential
used for authentication challenges. Created by calling one of the authenticate
methods.
var credential: URLCredential?
All URLRequests
created on behalf of the Request
, including original and adapted requests.
var requests: [URLRequest]
First URLRequest
created on behalf of the Request
. May not be the first one actually executed.
var firstRequest: URLRequest?
Last URLRequest
created on behalf of the Request
.
var lastRequest: URLRequest?
Current URLRequest
created on behalf of the Request
.
var request: URLRequest?
URLRequest
s from all of the URLSessionTask
s executed on behalf of the Request
. May be different from
requests
due to URLSession
manipulation.
var performedRequests: [URLRequest]
HTTPURLResponse
received from the server, if any. If the Request
was retried, this is the response of the
last URLSessionTask
.
var response: HTTPURLResponse?
All URLSessionTask
s created on behalf of the Request
.
var tasks: [URLSessionTask]
First URLSessionTask
created on behalf of the Request
.
var firstTask: URLSessionTask?
Last URLSessionTask
crated on behalf of the Request
.
var lastTask: URLSessionTask?
Current URLSessionTask
created on behalf of the Request
.
var task: URLSessionTask?
All URLSessionTaskMetrics
gathered on behalf of the Request
. Should correspond to the tasks
created.
var allMetrics: [URLSessionTaskMetrics]
First URLSessionTaskMetrics
gathered on behalf of the Request
.
var firstMetrics: URLSessionTaskMetrics?
Last URLSessionTaskMetrics
gathered on behalf of the Request
.
var lastMetrics: URLSessionTaskMetrics?
Current URLSessionTaskMetrics
gathered on behalf of the Request
.
var metrics: URLSessionTaskMetrics?
Number of times the Request
has been retried.
var retryCount: Int
Error
returned from Alamofire internally, from the network request directly, or any validators executed.
var error: AFError?
A textual representation of this instance, including the HTTPMethod
and URL
if the URLRequest
has been
created, as well as the response status code, if a response has been received.
var description: String
Cancels the instance. Once cancelled, a Request
can no longer be resumed or suspended.
@discardableResult public func cancel() -> Self
The instance.
Suspends the instance.
@discardableResult public func suspend() -> Self
The instance.
Resumes the instance.
@discardableResult public func resume() -> Self
The instance.
Associates a credential using the provided values with the instance.
@discardableResult public func authenticate(username: String, password: String, persistence: URLCredential.Persistence = .forSession) -> Self
- username: The username.
- password: The password.
- persistence: The
URLCredential.Persistence
for the createdURLCredential
..forSession
by default.
The instance.
Associates the provided credential with the instance.
@discardableResult public func authenticate(with credential: URLCredential) -> Self
- credential: The
URLCredential
.
The instance.
Sets a closure to be called periodically during the lifecycle of the instance as data is read from the server.
@discardableResult public func downloadProgress(queue: DispatchQueue = .main, closure: @escaping ProgressHandler) -> Self
- queue: The
DispatchQueue
to execute the closure on..main
by default. - closure: The closure to be executed periodically as data is read from the server.
The instance.
Sets a closure to be called periodically during the lifecycle of the instance as data is sent to the server.
@discardableResult public func uploadProgress(queue: DispatchQueue = .main, closure: @escaping ProgressHandler) -> Self
- queue: The
DispatchQueue
to execute the closure on..main
by default. - closure: The closure to be executed periodically as data is sent to the server.
The instance.
Sets the redirect handler for the instance which will be used if a redirect response is encountered.
@discardableResult public func redirect(using handler: RedirectHandler) -> Self
- handler: The
RedirectHandler
.
The instance.
Sets the cached response handler for the Request
which will be used when attempting to cache a response.
@discardableResult public func cacheResponse(using handler: CachedResponseHandler) -> Self
- handler: The
CachedResponseHandler
.
The instance.
Sets a handler to be called when the cURL description of the request is available.
@discardableResult public func cURLDescription(calling handler: @escaping (String) -> Void) -> Self
- handler: Closure to be called when the cURL description is available.
The instance.
public static func ==(lhs: Request, rhs: Request) -> Bool
public func hash(into hasher: inout Hasher)
cURL representation of the instance.
public func cURLDescription() -> String
The cURL equivalent of the instance.
Generated at 2020-09-24T22:11:06+0000 using swift-doc 1.0.0-beta.4.
Types
- AF
- AFError
- AFError.MultipartEncodingFailureReason
- AFError.ParameterEncoderFailureReason
- AFError.ParameterEncoderFailureReason.RequiredComponent
- AFError.ParameterEncodingFailureReason
- AFError.ResponseSerializationFailureReason
- AFError.ResponseValidationFailureReason
- AFError.ServerTrustFailureReason
- AFError.ServerTrustFailureReason.Output
- AFError.URLRequestValidationFailureReason
- Adapter
- AlamofireExtension
- AlamofireNotifications
- ClosureEventMonitor
- CompositeEventMonitor
- CompositeTrustEvaluator
- ConnectionLostRetryPolicy
- DataRequest
- DataResponse
- DataResponseSerializer
- DecodableResponseSerializer
- DefaultTrustEvaluator
- DisabledEvaluator
- DownloadRequest
- DownloadRequest.Downloadable
- DownloadRequest.Options
- DownloadResponse
- Empty
- GoogleXSSIPreprocessor
- HTTPHeader
- HTTPHeaders
- HTTPMethod
- Interceptor
- JSONEncoding
- JSONParameterEncoder
- JSONResponseSerializer
- MultipartFormData
- NetworkReachabilityManager
- NetworkReachabilityManager.NetworkReachabilityStatus
- NetworkReachabilityManager.NetworkReachabilityStatus.ConnectionType
- PassthroughPreprocessor
- PinnedCertificatesTrustEvaluator
- PublicKeysTrustEvaluator
- Redirector
- Redirector.Behavior
- Request
- Request.State
- ResponseCacher
- ResponseCacher.Behavior
- Retrier
- RetryPolicy
- RetryResult
- RevocationTrustEvaluator
- RevocationTrustEvaluator.Options
- ServerTrustManager
- Session
- SessionDelegate
- StringResponseSerializer
- URLEncodedFormEncoder
- URLEncodedFormEncoder.ArrayEncoding
- URLEncodedFormEncoder.BoolEncoding
- URLEncodedFormEncoder.DataEncoding
- URLEncodedFormEncoder.DateEncoding
- URLEncodedFormEncoder.Error
- URLEncodedFormEncoder.KeyEncoding
- URLEncodedFormEncoder.SpaceEncoding
- URLEncodedFormParameterEncoder
- URLEncodedFormParameterEncoder.Destination
- URLEncoding
- URLEncoding.ArrayEncoding
- URLEncoding.BoolEncoding
- URLEncoding.Destination
- UploadRequest
- UploadRequest.Uploadable
Protocols
- AlamofireExtended
- CachedResponseHandler
- DataDecoder
- DataPreprocessor
- DataResponseSerializerProtocol
- DownloadResponseSerializerProtocol
- EmptyResponse
- EventMonitor
- ParameterEncoder
- ParameterEncoding
- RedirectHandler
- RequestAdapter
- RequestDelegate
- RequestInterceptor
- RequestRetrier
- ResponseSerializer
- ServerTrustEvaluating
- URLConvertible
- URLRequestConvertible
- UploadConvertible
- UploadableConvertible