EventMonitor
public protocol EventMonitor : Sendable
Protocol outlining the lifetime events inside Alamofire. It includes both events received from the various
URLSession
delegate protocols as well as various events from the lifetime of Request
and its subclasses.
-
queue
Default implementationThe
DispatchQueue
onto which Alamofire’s rootCompositeEventMonitor
will dispatch events..main
by default.Default Implementation
The default queue on which
CompositeEventMonitor
s will call theEventMonitor
methods..main
by default.Declaration
Swift
var queue: DispatchQueue { get }
-
urlSession(_:
Default implementationdidBecomeInvalidWithError: ) Event called during
URLSessionDelegate
‘surlSession(_:didBecomeInvalidWithError:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, didBecomeInvalidWithError error: (any Error)?)
-
urlSession(_:
Default implementationtask: didReceive: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:task:didReceive:completionHandler:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge)
-
urlSession(_:
Default implementationtask: didSendBodyData: totalBytesSent: totalBytesExpectedToSend: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, task: URLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64)
-
urlSession(_:
Default implementationtaskNeedsNewBodyStream: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:task:needNewBodyStream:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, taskNeedsNewBodyStream task: URLSessionTask)
-
urlSession(_:
Default implementationtask: willPerformHTTPRedirection: newRequest: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest)
-
urlSession(_:
Default implementationtask: didFinishCollecting: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:task:didFinishCollecting:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics)
-
urlSession(_:
Default implementationtask: didCompleteWithError: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:task:didCompleteWithError:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: (any Error)?)
-
urlSession(_:
Default implementationtaskIsWaitingForConnectivity: ) Event called during
URLSessionTaskDelegate
‘surlSession(_:taskIsWaitingForConnectivity:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, taskIsWaitingForConnectivity task: URLSessionTask)
-
urlSession(_:
Default implementationdataTask: didReceive: ) Event called during
URLSessionDataDelegate
‘surlSession(_:dataTask:didReceive:completionHandler:)
method.Default Implementation
Undocumented
Declaration
Swift
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse)
-
Event called during
URLSessionDataDelegate
‘surlSession(_:dataTask:didReceive:)
method.Declaration
Swift
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data)
-
urlSession(_:
Default implementationdataTask: willCacheResponse: ) Event called during
URLSessionDataDelegate
‘surlSession(_:dataTask:willCacheResponse:completionHandler:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, willCacheResponse proposedResponse: CachedURLResponse)
-
urlSession(_:
Default implementationdownloadTask: didResumeAtOffset: expectedTotalBytes: ) Event called during
URLSessionDownloadDelegate
‘surlSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64)
-
urlSession(_:
Default implementationdownloadTask: didWriteData: totalBytesWritten: totalBytesExpectedToWrite: ) Event called during
URLSessionDownloadDelegate
‘surlSession(_:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64)
-
urlSession(_:
Default implementationdownloadTask: didFinishDownloadingTo: ) Event called during
URLSessionDownloadDelegate
‘surlSession(_:downloadTask:didFinishDownloadingTo:)
method.Default Implementation
Declaration
Swift
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL)
-
request(_:
Default implementationdidCreateInitialURLRequest: ) Event called when a
URLRequest
is first created for aRequest
. If aRequestAdapter
is active, theURLRequest
will be adapted before being issued.Default Implementation
Declaration
Swift
func request(_ request: Request, didCreateInitialURLRequest urlRequest: URLRequest)
-
request(_:
Default implementationdidFailToCreateURLRequestWithError: ) Event called when the attempt to create a
URLRequest
from aRequest
‘s originalURLRequestConvertible
value fails.Default Implementation
-
request(_:
Default implementationdidAdaptInitialRequest: to: ) Event called when a
RequestAdapter
adapts theRequest
‘s initialURLRequest
.Default Implementation
Declaration
Swift
func request(_ request: Request, didAdaptInitialRequest initialRequest: URLRequest, to adaptedRequest: URLRequest)
-
request(_:
Default implementationdidFailToAdaptURLRequest: withError: ) Event called when a
RequestAdapter
fails to adapt theRequest
‘s initialURLRequest
.Default Implementation
-
request(_:
Default implementationdidCreateURLRequest: ) -
request(_:
Default implementationdidCreateTask: ) -
request(_:
Default implementationdidGatherMetrics: ) -
request(_:
Default implementationdidFailTask: earlyWithError: ) -
request(_:
Default implementationdidCompleteTask: with: ) -
requestIsRetrying(_:
Default implementation) -
requestDidFinish(_:
Default implementation) -
requestDidResume(_:
Default implementation) -
request(_:
Default implementationdidResumeTask: ) -
requestDidSuspend(_:
Default implementation) -
request(_:
Default implementationdidSuspendTask: ) -
requestDidCancel(_:
Default implementation) -
request(_:
Default implementationdidCancelTask: )
-
request(_:
Default implementationdidValidateRequest: response: data: withResult: ) Event called when a
DataRequest
calls aValidation
.Default Implementation
Declaration
Swift
func request(_ request: DataRequest, didValidateRequest urlRequest: URLRequest?, response: HTTPURLResponse, data: Data?, withResult result: Request.ValidationResult)
-
request(_:
Default implementationdidParseResponse: ) Event called when a
DataRequest
creates aDataResponse<Data?>
value without calling aResponseSerializer
.Default Implementation
Undocumented
Declaration
Swift
func request(_ request: DataRequest, didParseResponse response: DataResponse<Data?, AFError>)
-
Event called when a
DataRequest
calls aResponseSerializer
and creates a genericDataResponse<Value, AFError>
.Declaration
Swift
func request<Value>(_ request: DataRequest, didParseResponse response: DataResponse<Value, AFError>) where Value : Sendable
-
request(_:
Default implementationdidValidateRequest: response: withResult: ) Event called when a
DataStreamRequest
calls aValidation
closure.Default Implementation
Declaration
Swift
func request(_ request: DataStreamRequest, didValidateRequest urlRequest: URLRequest?, response: HTTPURLResponse, withResult result: Request.ValidationResult)
Parameters
request
DataStreamRequest
which is calling theValidation
.urlRequest
URLRequest
of the request being validated.response
HTTPURLResponse
of the request being validated.result
Produced
ValidationResult
. -
request(_:
Default implementationdidParseStream: ) Event called when a
DataStreamSerializer
produces a value from streamedData
.Default Implementation
Declaration
Swift
func request<Value>(_ request: DataStreamRequest, didParseStream result: Result<Value, AFError>) where Value : Sendable
Parameters
request
DataStreamRequest
for which the value was serialized.result
Result
of the serialization attempt.
-
request(_:
Default implementationdidCreateUploadable: ) Event called when an
UploadRequest
creates itsUploadable
value, indicating the type of upload it represents.Default Implementation
Declaration
Swift
func request(_ request: UploadRequest, didCreateUploadable uploadable: UploadRequest.Uploadable)
-
request(_:
Default implementationdidFailToCreateUploadableWithError: ) Event called when an
UploadRequest
failed to create itsUploadable
value due to an error.Default Implementation
Declaration
Swift
func request(_ request: UploadRequest, didFailToCreateUploadableWithError error: AFError)
-
request(_:
Default implementationdidProvideInputStream: ) Event called when an
UploadRequest
provides theInputStream
from itsUploadable
value. This only occurs if theInputStream
does not wrap aData
value or fileURL
.Default Implementation
Declaration
Swift
func request(_ request: UploadRequest, didProvideInputStream stream: InputStream)
-
request(_:
Default implementationdidFinishDownloadingUsing: with: ) Event called when a
DownloadRequest
‘sURLSessionDownloadTask
finishes and the temporary file has been moved.Default Implementation
Declaration
Swift
func request(_ request: DownloadRequest, didFinishDownloadingUsing task: URLSessionTask, with result: Result<URL, AFError>)
-
request(_:
Default implementationdidCreateDestinationURL: ) Event called when a
DownloadRequest
‘sDestination
closure is called and creates the destination URL the downloaded file will be moved to.Default Implementation
Declaration
Swift
func request(_ request: DownloadRequest, didCreateDestinationURL url: URL)
-
request(_:
Default implementationdidValidateRequest: response: fileURL: withResult: ) Event called when a
DownloadRequest
calls aValidation
.Default Implementation
Declaration
Swift
func request(_ request: DownloadRequest, didValidateRequest urlRequest: URLRequest?, response: HTTPURLResponse, fileURL: URL?, withResult result: Request.ValidationResult)
-
Event called when a
DownloadRequest
creates aDownloadResponse<URL?, AFError>
without calling aResponseSerializer
.Declaration
Swift
func request(_ request: DownloadRequest, didParseResponse response: DownloadResponse<URL?, AFError>)
-
Event called when a
DownloadRequest
calls aDownloadResponseSerializer
and creates a genericDownloadResponse<Value, AFError>
Declaration
Swift
func request<Value>(_ request: DownloadRequest, didParseResponse response: DownloadResponse<Value, AFError>) where Value : Sendable