Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

DataResponseSerializer

mattt edited this page Sep 18, 2020 · 2 revisions

DataResponseSerializer

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 response is has a status code valid for empty responses (204, 205), then an empty Data value is returned.

public final class DataResponseSerializer:​ ResponseSerializer

Inheritance

ResponseSerializer

Initializers

init(dataPreprocessor:​emptyResponseCodes:​emptyRequestMethods:​)

Creates an instance using the provided values.

public init(dataPreprocessor:​ DataPreprocessor = DataResponseSerializer.defaultDataPreprocessor, emptyResponseCodes:​ Set<Int> = DataResponseSerializer.defaultEmptyResponseCodes, emptyRequestMethods:​ Set<HTTPMethod> = DataResponseSerializer.defaultEmptyRequestMethods)

Parameters

  • 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.

Properties

dataPreprocessor

let dataPreprocessor:​ DataPreprocessor

emptyResponseCodes

let emptyResponseCodes:​ Set<Int>

emptyRequestMethods

let emptyRequestMethods:​ Set<HTTPMethod>

Methods

serialize(request:​response:​data:​error:​)

public func serialize(request:​ URLRequest?, response:​ HTTPURLResponse?, data:​ Data?, error:​ Error?) throws -> Data
Types
Protocols
Global Typealiases
Clone this wiki locally