DataResponseSerializer
public final class DataResponseSerializer : ResponseSerializer
A ResponseSerializer that performs minimal response checking and returns any response Data as-is. By default, a
request returning nil or no data is considered an error. However, if the request has an HTTPMethod or the
response has an HTTP status code valid for empty responses, then an empty Data value is returned.
-
Declaration
Swift
public let dataPreprocessor: any DataPreprocessor -
Declaration
Swift
public let emptyResponseCodes: Set<Int> -
Declaration
Swift
public let emptyRequestMethods: Set<HTTPMethod> -
Creates a
DataResponseSerializerusing the provided parameters.Declaration
Swift
public init(dataPreprocessor: any DataPreprocessor = DataResponseSerializer.defaultDataPreprocessor, emptyResponseCodes: Set<Int> = DataResponseSerializer.defaultEmptyResponseCodes, emptyRequestMethods: Set<HTTPMethod> = DataResponseSerializer.defaultEmptyRequestMethods)Parameters
dataPreprocessorDataPreprocessorused to prepare the receivedDatafor serialization.emptyResponseCodesThe HTTP response codes for which empty responses are allowed.
[204, 205]by default.emptyRequestMethodsThe HTTP request methods for which empty responses are allowed.
[.head]by default. -
Declaration
Swift
public func serialize(request: URLRequest?, response: HTTPURLResponse?, data: Data?, error: (any Error)?) throws -> Data
View on GitHub
Install in Dash