SAPURLSessionTask

public class SAPURLSessionTask

This class is a wrapper class on top of URLSessionTask.

  • unique identifier of the SAPURLSessionTask

    Declaration

    Swift

    public let taskID: UUID
  • Internal URLSessionDataTask. Do not call resume on it.

    Declaration

    Swift

    public var urlSessionTask: URLSessionTask? { get }
  • The relative priority at which you’d like a host to handle the task, specified as a floating point value between 0.0 (lowest priority) and 1.0 (highest priority).

    Declaration

    Swift

    public var priority: Float { get set }
  • An app-provided description of the current task.

    Declaration

    Swift

    public var taskDescription: String?
  • The current state of the task—active, suspended, in the process of being canceled, or completed.

    Declaration

    Swift

    public var state: URLSessionTask.State { get }
  • The original request object passed when the task was created. This value is typically the same as the currently active request (currentRequest) except when the server has responded to the initial request with a redirect to a different URL, or the observers have modified it.

    Declaration

    Swift

    public let originalRequest: URLRequest?
  • The URL request object currently being handled by the task. This value is typically the same as the initial request (originalRequest) except when the server has responded to the initial request with a redirect to a different URL, or the observer have modified it.

    Declaration

    Swift

    public var currentRequest: URLRequest? { get }
  • The server’s response to the currently active request. This object provides information about the request as provided by the server. This information always includes the original URL. It may also include an expected length, MIME type information, encoding information, a suggested filename, or a combination of these. Note: The observers can modify this.

    Declaration

    Swift

    public var response: URLResponse? { get }
  • The context dictionary associated with the task. One can store here additional information about the task, which can be accessed in the delegate and observer methods. Note: This context dictionary is in memory only, not persisted.

    Declaration

    Swift

    public var context: [String : Any]
  • Resumes the task, if it is suspended.

    Declaration

    Swift

    public func resume()
  • Cancels the task. This method returns immediately, marking the task as being canceled. Once a task is marked as being canceled, urlSession(_:task:didCompleteWithError:) will be sent to the task delegate, passing an error in the domain NSURLErrorDomain with the code NSURLErrorCancelled. A task may, under some circumstances, send messages to its delegate before the cancelation is acknowledged. This method may be called on a task that is suspended.

    Declaration

    Swift

    public func cancel()
  • Temporarily suspends a task. A task, while suspended, produces no network traffic and is not subject to timeouts. A download task can continue transferring data at a later time. All other tasks must start over when resumed.

    Declaration

    Swift

    public func suspend()