ResponseSerializer
public protocol ResponseSerializer<SerializedObject> : DataResponseSerializerProtocol, DownloadResponseSerializerProtocol
A serializer that can handle both data and download responses.
-
dataPreprocessorDefault implementationDataPreprocessorused to prepare incomingDatafor serialization.Default Implementation
Declaration
Swift
var dataPreprocessor: any DataPreprocessor { get } -
emptyRequestMethodsDefault implementationHTTPMethods for which empty response bodies are considered appropriate.Default Implementation
Declaration
Swift
var emptyRequestMethods: Set<HTTPMethod> { get } -
emptyResponseCodesDefault implementationHTTP response codes for which empty response bodies are considered appropriate.
Default Implementation
Declaration
Swift
var emptyResponseCodes: Set<Int> { get } -
defaultDataPreprocessorExtension methodDefault
DataPreprocessor.PassthroughPreprocessorby default.Declaration
Swift
public static var defaultDataPreprocessor: any DataPreprocessor { get } -
defaultEmptyRequestMethodsExtension methodDefault
HTTPMethods for which empty response bodies are always considered appropriate.[.head]by default.Declaration
Swift
public static var defaultEmptyRequestMethods: Set<HTTPMethod> { get } -
defaultEmptyResponseCodesExtension methodHTTP response codes for which empty response bodies are always considered appropriate.
[204, 205]by default.Declaration
Swift
public static var defaultEmptyResponseCodes: Set<Int> { get } -
requestAllowsEmptyResponseData(_:Extension method) Determines whether the
requestallows empty response bodies, ifrequestexists.Declaration
Swift
public func requestAllowsEmptyResponseData(_ request: URLRequest?) -> Bool?Parameters
requestURLRequestto evaluate.Return Value
Boolrepresenting the outcome of the evaluation, ornilifrequestwasnil. -
responseAllowsEmptyResponseData(_:Extension method) Determines whether the
responseallows empty response bodies, ifresponseexists.Declaration
Swift
public func responseAllowsEmptyResponseData(_ response: HTTPURLResponse?) -> Bool?Parameters
responseHTTPURLResponseto evaluate.Return Value
Boolrepresenting the outcome of the evaluation, ornilifresponsewasnil. -
emptyResponseAllowed(forRequest:Extension methodresponse: ) Determines whether
requestandresponseallow empty response bodies.Declaration
Swift
public func emptyResponseAllowed(forRequest request: URLRequest?, response: HTTPURLResponse?) -> BoolParameters
requestURLRequestto evaluate.responseHTTPURLResponseto evaluate.Return Value
trueifrequestorresponseallow empty bodies,falseotherwise.
-
Creates a
DecodableResponseSerializerusing the values provided.Declaration
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>Parameters
typeDecodabletype to decode from response data.dataPreprocessorDataPreprocessorused to prepare the receivedDatafor serialization.decoderThe
DataDecoder.JSONDecoder()by default.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.Return Value
-
dataExtension methodProvides a default
DataResponseSerializerinstance.Declaration
Swift
public static var data: DataResponseSerializer { get } -
data(dataPreprocessor:Extension methodemptyResponseCodes: emptyRequestMethods: ) Creates a
DataResponseSerializerusing the provided parameters.Declaration
Swift
public static func data(dataPreprocessor: any DataPreprocessor = DataResponseSerializer.defaultDataPreprocessor, emptyResponseCodes: Set<Int> = DataResponseSerializer.defaultEmptyResponseCodes, emptyRequestMethods: Set<HTTPMethod> = DataResponseSerializer.defaultEmptyRequestMethods) -> DataResponseSerializerParameters
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.Return Value
-
stringExtension methodProvides a default
StringResponseSerializerinstance.Declaration
Swift
public static var string: StringResponseSerializer { get } -
Creates a
StringResponseSerializerwith the provided values.Declaration
Swift
public static func string(dataPreprocessor: any DataPreprocessor = StringResponseSerializer.defaultDataPreprocessor, encoding: String.Encoding? = nil, emptyResponseCodes: Set<Int> = StringResponseSerializer.defaultEmptyResponseCodes, emptyRequestMethods: Set<HTTPMethod> = StringResponseSerializer.defaultEmptyRequestMethods) -> StringResponseSerializerParameters
dataPreprocessorDataPreprocessorused to prepare the receivedDatafor serialization.encodingA 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.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.Return Value
View on GitHub
Install in Dash