ClosureEventMonitor
open class ClosureEventMonitor : EventMonitor, @unchecked Sendable
EventMonitor
that allows optional closures to be set to receive events.
-
Closure called on the
urlSession(_:didBecomeInvalidWithError:)
event.Declaration
Swift
open var sessionDidBecomeInvalidWithError: ((URLSession, (any Error)?) -> Void)?
-
Closure called on the
urlSession(_:task:didReceive:completionHandler:)
.Declaration
Swift
open var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> Void)?
-
Closure that receives
urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)
event.Declaration
Swift
open var taskDidSendBodyData: ((URLSession, URLSessionTask, Int64, Int64, Int64) -> Void)?
-
Closure called on the
urlSession(_:task:needNewBodyStream:)
event.Declaration
Swift
open var taskNeedNewBodyStream: ((URLSession, URLSessionTask) -> Void)?
-
Closure called on the
urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)
event.Declaration
Swift
open var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> Void)?
-
Closure called on the
urlSession(_:task:didFinishCollecting:)
event.Declaration
Swift
open var taskDidFinishCollectingMetrics: ((URLSession, URLSessionTask, URLSessionTaskMetrics) -> Void)?
-
Closure called on the
urlSession(_:task:didCompleteWithError:)
event.Declaration
Swift
open var taskDidComplete: ((URLSession, URLSessionTask, (any Error)?) -> Void)?
-
Closure called on the
urlSession(_:taskIsWaitingForConnectivity:)
event.Declaration
Swift
open var taskIsWaitingForConnectivity: ((URLSession, URLSessionTask) -> Void)?
-
Closure called on the
urlSession(_:dataTask:didReceive:completionHandler:)
event.Declaration
Swift
open var dataTaskDidReceiveResponse: ((URLSession, URLSessionDataTask, URLResponse) -> Void)?
-
Closure that receives the
urlSession(_:dataTask:didReceive:)
event.Declaration
Swift
open var dataTaskDidReceiveData: ((URLSession, URLSessionDataTask, Data) -> Void)?
-
Closure called on the
urlSession(_:dataTask:willCacheResponse:completionHandler:)
event.Declaration
Swift
open var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> Void)?
-
Closure called on the
urlSession(_:downloadTask:didFinishDownloadingTo:)
event.Declaration
Swift
open var downloadTaskDidFinishDownloadingToURL: ((URLSession, URLSessionDownloadTask, URL) -> Void)?
-
Closure called on the
urlSession(_:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:)
event.Declaration
Swift
open var downloadTaskDidWriteData: ((URLSession, URLSessionDownloadTask, Int64, Int64, Int64) -> Void)?
-
Closure called on the
urlSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:)
event.Declaration
Swift
open var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)?
-
Closure called on the
request(_:didCreateInitialURLRequest:)
event.Declaration
Swift
open var requestDidCreateInitialURLRequest: ((Request, URLRequest) -> Void)?
-
Closure called on the
request(_:didFailToCreateURLRequestWithError:)
event. -
Closure called on the
request(_:didAdaptInitialRequest:to:)
event.Declaration
Swift
open var requestDidAdaptInitialRequestToAdaptedRequest: ((Request, URLRequest, URLRequest) -> Void)?
-
Closure called on the
request(_:didFailToAdaptURLRequest:withError:)
event. -
Closure called on the
request(_:didCreateURLRequest:)
event.Declaration
Swift
open var requestDidCreateURLRequest: ((Request, URLRequest) -> Void)?
-
Closure called on the
request(_:didCreateTask:)
event.Declaration
Swift
open var requestDidCreateTask: ((Request, URLSessionTask) -> Void)?
-
Closure called on the
request(_:didGatherMetrics:)
event.Declaration
Swift
open var requestDidGatherMetrics: ((Request, URLSessionTaskMetrics) -> Void)?
-
Closure called on the
request(_:didFailTask:earlyWithError:)
event. -
Closure called on the
request(_:didCompleteTask:with:)
event. -
Closure called on the
requestIsRetrying(_:)
event.Declaration
Swift
open var requestIsRetrying: ((Request) -> Void)?
-
Closure called on the
requestDidFinish(_:)
event.Declaration
Swift
open var requestDidFinish: ((Request) -> Void)?
-
Closure called on the
requestDidResume(_:)
event.Declaration
Swift
open var requestDidResume: ((Request) -> Void)?
-
Closure called on the
request(_:didResumeTask:)
event.Declaration
Swift
open var requestDidResumeTask: ((Request, URLSessionTask) -> Void)?
-
Closure called on the
requestDidSuspend(_:)
event.Declaration
Swift
open var requestDidSuspend: ((Request) -> Void)?
-
Closure called on the
request(_:didSuspendTask:)
event.Declaration
Swift
open var requestDidSuspendTask: ((Request, URLSessionTask) -> Void)?
-
Closure called on the
requestDidCancel(_:)
event.Declaration
Swift
open var requestDidCancel: ((Request) -> Void)?
-
Closure called on the
request(_:didCancelTask:)
event.Declaration
Swift
open var requestDidCancelTask: ((Request, URLSessionTask) -> Void)?
-
Closure called on the
request(_:didValidateRequest:response:data:withResult:)
event.Declaration
Swift
open var requestDidValidateRequestResponseDataWithResult: ((DataRequest, URLRequest?, HTTPURLResponse, Data?, Request.ValidationResult) -> Void)?
-
Closure called on the
request(_:didParseResponse:)
event.Declaration
Swift
open var requestDidParseResponse: ((DataRequest, DataResponse<Data?, AFError>) -> Void)?
-
Closure called on the
request(_:didValidateRequest:response:withResult:)
event.Declaration
Swift
open var requestDidValidateRequestResponseWithResult: ((DataStreamRequest, URLRequest?, HTTPURLResponse, Request.ValidationResult) -> Void)?
-
Closure called on the
request(_:didCreateUploadable:)
event.Declaration
Swift
open var requestDidCreateUploadable: ((UploadRequest, UploadRequest.Uploadable) -> Void)?
-
Closure called on the
request(_:didFailToCreateUploadableWithError:)
event.Declaration
Swift
open var requestDidFailToCreateUploadableWithError: ((UploadRequest, AFError) -> Void)?
-
Closure called on the
request(_:didProvideInputStream:)
event.Declaration
Swift
open var requestDidProvideInputStream: ((UploadRequest, InputStream) -> Void)?
-
Closure called on the
request(_:didFinishDownloadingUsing:with:)
event.Declaration
Swift
open var requestDidFinishDownloadingUsingTaskWithResult: ((DownloadRequest, URLSessionTask, Result<URL, AFError>) -> Void)?
-
Closure called on the
request(_:didCreateDestinationURL:)
event.Declaration
Swift
open var requestDidCreateDestinationURL: ((DownloadRequest, URL) -> Void)?
-
Closure called on the
request(_:didValidateRequest:response:temporaryURL:destinationURL:withResult:)
event.Declaration
Swift
open var requestDidValidateRequestResponseFileURLWithResult: ((DownloadRequest, URLRequest?, HTTPURLResponse, URL?, Request.ValidationResult) -> Void)?
-
Closure called on the
request(_:didParseResponse:)
event.Declaration
Swift
open var requestDidParseDownloadResponse: ((DownloadRequest, DownloadResponse<URL?, AFError>) -> Void)?
-
Declaration
Swift
public let queue: DispatchQueue
-
Creates an instance using the provided queue.
Declaration
Swift
public init(queue: DispatchQueue = .main)
Parameters
queue
DispatchQueue
on which events will fired..main
by default. -
Declaration
Swift
open func urlSession(_ session: URLSession, didBecomeInvalidWithError error: (any Error)?)
-
Declaration
Swift
open func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge)
-
Declaration
Swift
open func urlSession(_ session: URLSession, task: URLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64)
-
Declaration
Swift
open func urlSession(_ session: URLSession, taskNeedsNewBodyStream task: URLSessionTask)
-
Declaration
Swift
open func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest)
-
Declaration
Swift
open func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics)
-
Declaration
Swift
open func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: (any Error)?)
-
Declaration
Swift
open func urlSession(_ session: URLSession, taskIsWaitingForConnectivity task: URLSessionTask)
-
Declaration
Swift
open func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse)
-
Declaration
Swift
open func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data)
-
Declaration
Swift
open func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, willCacheResponse proposedResponse: CachedURLResponse)
-
Declaration
Swift
open func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64)
-
Declaration
Swift
open func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64)
-
Declaration
Swift
open func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL)
-
Declaration
Swift
open func request(_ request: Request, didCreateInitialURLRequest urlRequest: URLRequest)
-
Declaration
Swift
open func request(_ request: Request, didAdaptInitialRequest initialRequest: URLRequest, to adaptedRequest: URLRequest)
-
Declaration
Swift
open func request(_ request: Request, didCreateURLRequest urlRequest: URLRequest)
-
Declaration
Swift
open func request(_ request: Request, didCreateTask task: URLSessionTask)
-
Declaration
Swift
open func request(_ request: Request, didGatherMetrics metrics: URLSessionTaskMetrics)
-
Declaration
Swift
open func requestIsRetrying(_ request: Request)
-
Declaration
Swift
open func requestDidFinish(_ request: Request)
-
Declaration
Swift
open func requestDidResume(_ request: Request)
-
Declaration
Swift
public func request(_ request: Request, didResumeTask task: URLSessionTask)
-
Declaration
Swift
open func requestDidSuspend(_ request: Request)
-
Declaration
Swift
public func request(_ request: Request, didSuspendTask task: URLSessionTask)
-
Declaration
Swift
open func requestDidCancel(_ request: Request)
-
Declaration
Swift
public func request(_ request: Request, didCancelTask task: URLSessionTask)
-
Declaration
Swift
open func request(_ request: DataRequest, didValidateRequest urlRequest: URLRequest?, response: HTTPURLResponse, data: Data?, withResult result: Request.ValidationResult)
-
Declaration
Swift
open func request(_ request: DataRequest, didParseResponse response: DataResponse<Data?, AFError>)
-
Declaration
Swift
public func request(_ request: DataStreamRequest, didValidateRequest urlRequest: URLRequest?, response: HTTPURLResponse, withResult result: Request.ValidationResult)
-
Declaration
Swift
open func request(_ request: UploadRequest, didCreateUploadable uploadable: UploadRequest.Uploadable)
-
Declaration
Swift
open func request(_ request: UploadRequest, didFailToCreateUploadableWithError error: AFError)
-
Declaration
Swift
open func request(_ request: UploadRequest, didProvideInputStream stream: InputStream)
-
Declaration
Swift
open func request(_ request: DownloadRequest, didFinishDownloadingUsing task: URLSessionTask, with result: Result<URL, AFError>)
-
Declaration
Swift
open func request(_ request: DownloadRequest, didCreateDestinationURL url: URL)
-
Declaration
Swift
open func request(_ request: DownloadRequest, didValidateRequest urlRequest: URLRequest?, response: HTTPURLResponse, fileURL: URL?, withResult result: Request.ValidationResult)
-
Declaration
Swift
open func request(_ request: DownloadRequest, didParseResponse response: DownloadResponse<URL?, AFError>)