docs/docsets/Alamofire.docset/Contents/Resources/Documents/Protocols/ResponseSerializer.html
public protocol ResponseSerializer<SerializedObject> : DataResponseSerializerProtocol, DownloadResponseSerializerProtocol
A serializer that can handle both data and download responses.
`
dataPreprocessor
` Default implementation
DataPreprocessor used to prepare incoming Data for serialization.
Swift
var dataPreprocessor: any DataPreprocessor { get }
`
emptyRequestMethods
` Default implementation
HTTPMethods for which empty response bodies are considered appropriate.
Swift
var emptyRequestMethods: Set<HTTPMethod> { get }
`
emptyResponseCodes
` Default implementation
HTTP response codes for which empty response bodies are considered appropriate.
Swift
var emptyResponseCodes: Set<Int> { get }
`
defaultDataPreprocessor
` Extension method
Default DataPreprocessor. PassthroughPreprocessor by default.
Swift
public static var defaultDataPreprocessor: any DataPreprocessor { get }
`
defaultEmptyRequestMethods
` Extension method
Default HTTPMethods for which empty response bodies are always considered appropriate. [.head] by default.
Swift
public static var defaultEmptyRequestMethods: Set<HTTPMethod> { get }
`
defaultEmptyResponseCodes
` Extension method
HTTP response codes for which empty response bodies are always considered appropriate. [204, 205] by default.
Swift
public static var defaultEmptyResponseCodes: Set<Int> { get }
`
requestAllowsEmptyResponseData(_:)
` Extension method
Determines whether the request allows empty response bodies, if request exists.
Swift
public func requestAllowsEmptyResponseData(_ request: URLRequest?) -> Bool?
| request |
URLRequest to evaluate.
|
Bool representing the outcome of the evaluation, or nil if request was nil.
`
responseAllowsEmptyResponseData(_:)
` Extension method
Determines whether the response allows empty response bodies, if response exists.
Swift
public func responseAllowsEmptyResponseData(_ response: HTTPURLResponse?) -> Bool?
| response |
HTTPURLResponse to evaluate.
|
Bool representing the outcome of the evaluation, or nil if response was nil.
`
emptyResponseAllowed(forRequest:response:)
` Extension method
Determines whether request and response allow empty response bodies.
Swift
public func emptyResponseAllowed(forRequest request: URLRequest?, response: HTTPURLResponse?) -> Bool
| request |
URLRequest to evaluate.
|
| response |
HTTPURLResponse to evaluate.
|
true if request or response allow empty bodies, false otherwise.
`
decodable(of:dataPreprocessor:decoder:emptyResponseCodes:emptyRequestMethods:)
` Extension method
Creates a DecodableResponseSerializer using the values provided.
Swift
public static func decodable<T: Decodable>(of type: T.Type,
dataPreprocessor: any DataPreprocessor = DecodableResponseSerializer<T>.defaultDataPreprocessor,
decoder: any DataDecoder = JSONDecoder(),
emptyResponseCodes: Set<Int> = DecodableResponseSerializer<T>.defaultEmptyResponseCodes,
emptyRequestMethods: Set<HTTPMethod> = DecodableResponseSerializer<T>.defaultEmptyRequestMethods) -> DecodableResponseSerializer<T> where Self == DecodableResponseSerializer<T>
| type |
Decodable type to decode from response data.
|
| dataPreprocessor |
DataPreprocessor used to prepare the received Data for serialization.
|
| decoder |
The DataDecoder. JSONDecoder() by default.
|
| emptyResponseCodes |
The HTTP response codes for which empty responses are allowed. [204, 205] by default.
|
| emptyRequestMethods |
The HTTP request methods for which empty responses are allowed. [.head] by default.
|
The DecodableResponseSerializer.
Self == DataResponseSerializer`
data
` Extension method
Provides a default DataResponseSerializer instance.
Swift
public static var data: DataResponseSerializer { get }
`
data(dataPreprocessor:emptyResponseCodes:emptyRequestMethods:)
` Extension method
Creates a DataResponseSerializer using the provided parameters.
Swift
public static func data(dataPreprocessor: any DataPreprocessor = DataResponseSerializer.defaultDataPreprocessor,
emptyResponseCodes: Set<Int> = DataResponseSerializer.defaultEmptyResponseCodes,
emptyRequestMethods: Set<HTTPMethod> = DataResponseSerializer.defaultEmptyRequestMethods) -> DataResponseSerializer
| dataPreprocessor |
DataPreprocessor used to prepare the received Data for serialization.
|
| emptyResponseCodes |
The HTTP response codes for which empty responses are allowed. [204, 205] by default.
|
| emptyRequestMethods |
The HTTP request methods for which empty responses are allowed. [.head] by default.
|
The DataResponseSerializer.
Self == StringResponseSerializer`
string
` Extension method
Provides a default StringResponseSerializer instance.
Swift
public static var string: StringResponseSerializer { get }
`
string(dataPreprocessor:encoding:emptyResponseCodes:emptyRequestMethods:)
` Extension method
Creates a StringResponseSerializer with the provided values.
Swift
public static func string(dataPreprocessor: any DataPreprocessor = StringResponseSerializer.defaultDataPreprocessor,
encoding: String.Encoding? = nil,
emptyResponseCodes: Set<Int> = StringResponseSerializer.defaultEmptyResponseCodes,
emptyRequestMethods: Set<HTTPMethod> = StringResponseSerializer.defaultEmptyRequestMethods) -> StringResponseSerializer
| dataPreprocessor |
DataPreprocessor used to prepare the received Data for serialization.
|
| encoding |
A string encoding. Defaults to nil, in which case the encoding will be determined from the server response, falling back to the default HTTP character set, ISO-8859-1.
|
| emptyResponseCodes |
The HTTP response codes for which empty responses are allowed. [204, 205] by default.
|
| emptyRequestMethods |
The HTTP request methods for which empty responses are allowed. [.head] by default.
|
The StringResponseSerializer.