-
The progress of fetching the response data from the server for the request.
Declaration
Swift
open var progress: Progress
-
Sets a closure to be called periodically during the lifecycle of the request as data is read from the server.
This closure returns the bytes most recently received from the server, not including data from previous calls. If this closure is set, data will only be available within this closure, and will not be saved elsewhere. It is also important to note that the server data in any
Response
object will benil
.Declaration
Swift
open func stream(closure: ((Data) -> Void)? = nil) -> Self
-
Sets a closure to be called periodically during the lifecycle of the
Request
as data is read from the server.Declaration
Swift
open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self
-
Adds the content types specified to the list of acceptable images content types for validation.
Declaration
Swift
public class func addAcceptableImageContentTypes(_ contentTypes: Set<String>)
-
Creates a response serializer that returns an image initialized from the response data using the specified image options.
Declaration
Swift
public class func imageResponseSerializer( imageScale: CGFloat = DataRequest.imageScale, inflateResponseImage: Bool = true) -> DataResponseSerializer<Image>
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func responseImage( imageScale: CGFloat = DataRequest.imageScale, inflateResponseImage: Bool = true, completionHandler: @escaping (DataResponse<Image>) -> Void) -> Self
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func response(queue: DispatchQueue? = nil, completionHandler: @escaping (DefaultDataResponse) -> Void) -> Self
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func response<T: DataResponseSerializerProtocol>( queue: DispatchQueue? = nil, responseSerializer: T, completionHandler: @escaping (DataResponse<T.SerializedObject>) -> Void) -> Self
-
Creates a response serializer that returns the associated data as-is.
Declaration
Swift
public static func dataResponseSerializer() -> DataResponseSerializer<Data>
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func responseData( queue: DispatchQueue? = nil, completionHandler: @escaping (DataResponse<Data>) -> Void) -> Self
-
Creates a response serializer that returns a result string type initialized from the response data with the specified string encoding.
Declaration
Swift
public static func stringResponseSerializer(encoding: String.Encoding? = nil) -> DataResponseSerializer<String>
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func responseString( queue: DispatchQueue? = nil, encoding: String.Encoding? = nil, completionHandler: @escaping (DataResponse<String>) -> Void) -> Self
-
Creates a response serializer that returns a JSON object result type constructed from the response data using
JSONSerialization
with the specified reading options.Declaration
Swift
public static func jsonResponseSerializer( options: JSONSerialization.ReadingOptions = .allowFragments) -> DataResponseSerializer<Any>
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func responseJSON( queue: DispatchQueue? = nil, options: JSONSerialization.ReadingOptions = .allowFragments, completionHandler: @escaping (DataResponse<Any>) -> Void) -> Self
-
Creates a response serializer that returns an object constructed from the response data using
PropertyListSerialization
with the specified reading options.Declaration
Swift
public static func propertyListResponseSerializer( options: PropertyListSerialization.ReadOptions = []) -> DataResponseSerializer<Any>
-
Adds a handler to be called once the request has finished.
Declaration
Swift
public func responsePropertyList( queue: DispatchQueue? = nil, options: PropertyListSerialization.ReadOptions = [], completionHandler: @escaping (DataResponse<Any>) -> Void) -> Self
-
Validates the request, using the specified closure.
If validation fails, subsequent calls to response handlers will have an associated error.
Declaration
Swift
public func validate(_ validation: @escaping Validation) -> Self
-
Validates that the response has a status code in the specified sequence.
If validation fails, subsequent calls to response handlers will have an associated error.
Declaration
Swift
public func validate<S: Sequence>(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int
-
Validates that the response has a content type in the specified sequence.
If validation fails, subsequent calls to response handlers will have an associated error.
Declaration
Swift
public func validate<S: Sequence>(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String
-
Validates that the response has a status code in the default acceptable range of 200…299, and that the content type matches any specified in the Accept HTTP header field.
If validation fails, subsequent calls to response handlers will have an associated error.
Declaration
Swift
public func validate() -> Self