Request
open class Request
Responsible for sending a request and receiving the response and associated data from the server, as well as
managing its underlying URLSessionTask
.
-
A closure executed when monitoring upload or download progress of a request.
Declaration
Swift
public typealias ProgressHandler = (Progress) -> Void
-
The delegate for the underlying task.
Declaration
Swift
open internal(set) var delegate: TaskDelegate
-
The underlying task.
Declaration
Swift
open var task: URLSessionTask?
-
The session belonging to the underlying task.
Declaration
Swift
open let session: URLSession
-
The request sent or to be sent to the server.
Declaration
Swift
open var request: URLRequest?
-
The response received from the server, if any.
Declaration
Swift
open var response: HTTPURLResponse?
-
Associates an HTTP Basic credential with the request.
Declaration
Swift
open func authenticate( user: String, password: String, persistence: URLCredential.Persistence = .forSession) -> Self
-
Associates a specified credential with the request.
Declaration
Swift
open func authenticate(usingCredential credential: URLCredential) -> Self
-
Returns a base64 encoded basic authentication credential as an authorization header tuple.
Declaration
Swift
open static func authorizationHeader(user: String, password: String) -> (key: String, value: String)?
-
Resumes the request.
Declaration
Swift
open func resume()
-
Suspends the request.
Declaration
Swift
open func suspend()
-
Cancels the request.
Declaration
Swift
open func cancel()
-
Returns a result data type that contains the response data as-is.
Declaration
Swift
public static func serializeResponseData(response: HTTPURLResponse?, data: Data?, error: Error?) -> Result<Data>
-
Returns a result string type initialized from the response data with the specified string encoding.
Declaration
Swift
public static func serializeResponseString( encoding: String.Encoding?, response: HTTPURLResponse?, data: Data?, error: Error?) -> Result<String>
-
Returns a JSON object contained in a result type constructed from the response data using
JSONSerialization
with the specified reading options.Declaration
Swift
public static func serializeResponseJSON( options: JSONSerialization.ReadingOptions, response: HTTPURLResponse?, data: Data?, error: Error?) -> Result<Any>
-
Returns a plist object contained in a result type constructed from the response data using
PropertyListSerialization
with the specified reading options.Declaration
Swift
public static func serializeResponsePropertyList( options: PropertyListSerialization.ReadOptions, response: HTTPURLResponse?, data: Data?, error: Error?) -> Result<Any>
-
The textual representation used when written to an output stream, which includes the HTTP method and URL, as well as the response status code if a response has been received.
Declaration
Swift
open var description: String
-
The textual representation used when written to an output stream, in the form of a cURL command.
Declaration
Swift
open var debugDescription: String
-
Used to represent whether validation was successful or encountered an error resulting in a failure.
- success: The validation was successful.
- failure: The validation failed encountering the provided error.
Declaration
Swift
public enum ValidationResult