Interface NSURLSessionTaskDelegate

    • Method Detail

      • URLSessionTaskDidCompleteWithError

        default void URLSessionTaskDidCompleteWithError​(@NotNull
                                                        @NotNull NSURLSession session,
                                                        @NotNull
                                                        @NotNull NSURLSessionTask task,
                                                        @Nullable
                                                        @Nullable NSError error)
        Sent as the last message related to a specific task. Error may be nil, which implies that no error occurred and this task is complete.
      • URLSessionTaskDidFinishCollectingMetrics

        default void URLSessionTaskDidFinishCollectingMetrics​(@NotNull
                                                              @NotNull NSURLSession session,
                                                              @NotNull
                                                              @NotNull NSURLSessionTask task,
                                                              @NotNull
                                                              @NotNull NSURLSessionTaskMetrics metrics)
        Sent when complete statistics information has been collected for the task. API-Since: 10.0
      • URLSessionTaskDidSendBodyDataTotalBytesSentTotalBytesExpectedToSend

        default void URLSessionTaskDidSendBodyDataTotalBytesSentTotalBytesExpectedToSend​(@NotNull
                                                                                         @NotNull NSURLSession session,
                                                                                         @NotNull
                                                                                         @NotNull NSURLSessionTask task,
                                                                                         long bytesSent,
                                                                                         long totalBytesSent,
                                                                                         long totalBytesExpectedToSend)
        Sent periodically to notify the delegate of upload progress. This information is also available as properties of the task.
      • URLSessionTaskWillPerformHTTPRedirectionNewRequestCompletionHandler

        default void URLSessionTaskWillPerformHTTPRedirectionNewRequestCompletionHandler​(@NotNull
                                                                                         @NotNull NSURLSession session,
                                                                                         @NotNull
                                                                                         @NotNull NSURLSessionTask task,
                                                                                         @NotNull
                                                                                         @NotNull NSHTTPURLResponse response,
                                                                                         @NotNull
                                                                                         @NotNull NSURLRequest request,
                                                                                         @NotNull
                                                                                         @NotNull NSURLSessionTaskDelegate.Block_URLSessionTaskWillPerformHTTPRedirectionNewRequestCompletionHandler completionHandler)
        An HTTP request is attempting to perform a redirection to a different URL. You must invoke the completion routine to allow the redirection, allow the redirection with a modified request, or pass nil to the completionHandler to cause the body of the redirection response to be delivered as the payload of this request. The default is to follow redirections. For tasks in background sessions, redirections will always be followed and this method will not be called.
      • URLSessionTaskWillBeginDelayedRequestCompletionHandler

        default void URLSessionTaskWillBeginDelayedRequestCompletionHandler​(@NotNull
                                                                            @NotNull NSURLSession session,
                                                                            @NotNull
                                                                            @NotNull NSURLSessionTask task,
                                                                            @NotNull
                                                                            @NotNull NSURLRequest request,
                                                                            @NotNull
                                                                            @NotNull NSURLSessionTaskDelegate.Block_URLSessionTaskWillBeginDelayedRequestCompletionHandler completionHandler)
        Sent when the system is ready to begin work for a task with a delayed start time set (using the earliestBeginDate property). The completionHandler must be invoked in order for loading to proceed. The disposition provided to the completion handler continues the load with the original request provided to the task, replaces the request with the specified task, or cancels the task. If this delegate is not implemented, loading will proceed with the original request. Recommendation: only implement this delegate if tasks that have the earliestBeginDate property set may become stale and require alteration prior to starting the network load. If a new request is specified, the allowsExpensiveNetworkAccess, allowsConstrainedNetworkAccess, and allowsCellularAccess properties from the new request will not be used; the properties from the original request will continue to be used. Canceling the task is equivalent to calling the task's cancel method; the URLSession:task:didCompleteWithError: task delegate will be called with error NSURLErrorCancelled. API-Since: 11.0
      • URLSessionTaskIsWaitingForConnectivity

        default void URLSessionTaskIsWaitingForConnectivity​(@NotNull
                                                            @NotNull NSURLSession session,
                                                            @NotNull
                                                            @NotNull NSURLSessionTask task)
        Sent when a task cannot start the network loading process because the current network connectivity is not available or sufficient for the task's request. This delegate will be called at most one time per task, and is only called if the waitsForConnectivity property in the NSURLSessionConfiguration has been set to YES. This delegate callback will never be called for background sessions, because the waitForConnectivity property is ignored by those sessions. API-Since: 11.0
      • URLSessionDidCreateTask

        default void URLSessionDidCreateTask​(@NotNull
                                             @NotNull NSURLSession session,
                                             @NotNull
                                             @NotNull NSURLSessionTask task)
        Notification that a task has been created. This method is the first message a task sends, providing a place to configure the task before it is resumed. This delegate callback is *NOT* dispatched to the delegate queue. It is invoked synchronously before the task creation method returns. API-Since: 16.0
      • URLSessionTaskDidReceiveInformationalResponse

        default void URLSessionTaskDidReceiveInformationalResponse​(@NotNull
                                                                   @NotNull NSURLSession session,
                                                                   @NotNull
                                                                   @NotNull NSURLSessionTask task,
                                                                   @NotNull
                                                                   @NotNull NSHTTPURLResponse response)
        Sent for each informational response received except 101 switching protocols. API-Since: 17.0
      • URLSessionTaskNeedNewBodyStreamFromOffsetCompletionHandler

        default void URLSessionTaskNeedNewBodyStreamFromOffsetCompletionHandler​(@NotNull
                                                                                @NotNull NSURLSession session,
                                                                                @NotNull
                                                                                @NotNull NSURLSessionTask task,
                                                                                long offset,
                                                                                @NotNull
                                                                                @NotNull NSURLSessionTaskDelegate.Block_URLSessionTaskNeedNewBodyStreamFromOffsetCompletionHandler completionHandler)
        Tells the delegate if a task requires a new body stream starting from the given offset. This may be necessary when resuming a failed upload task. - Parameter session: The session containing the task that needs a new body stream from the given offset. - Parameter task: The task that needs a new body stream. - Parameter offset: The starting offset required for the body stream. - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream. API-Since: 17.0