LCHTTPResponseSerializer
Objective-C
@interface LCHTTPResponseSerializer : NSObject <LCURLResponseSerialization>
Swift
class LCHTTPResponseSerializer : NSObject, LCURLResponseSerialization
LCHTTPResponseSerializer conforms to the LCURLRequestSerialization & LCURLResponseSerialization protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
Any request or response serializer dealing with HTTP is encouraged to subclass LCHTTPResponseSerializer in order to ensure consistent default behavior.
-
Undocumented
Declaration
Objective-C
- (instancetype)init;Swift
init() -
Deprecated
The string encoding is never used. LCHTTPResponseSerializer only validates status codes and content types but does not try to decode the received data in any way.
Undocumented
Declaration
Objective-C
@property (nonatomic) NSStringEncoding stringEncodingSwift
var stringEncoding: UInt { get set } -
Creates and returns a serializer with default configuration.
Declaration
Objective-C
+ (nonnull instancetype)serializer;
-
The acceptable HTTP status codes for responses. When non-
nil, responses with status codes not contained by the set will result in an error during validation.Declaration
Objective-C
@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;Swift
var acceptableStatusCodes: IndexSet? { get set } -
The acceptable MIME types for responses. When non-
nil, responses with aContent-Typewith MIME types that do not intersect with the set will result in an error during validation.Declaration
Objective-C
@property (nonatomic, copy, nullable) NSSet<NSString *> *acceptableContentTypes;Swift
var acceptableContentTypes: Set<String>? { get set } -
Validates the specified response and data.
In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
Declaration
Objective-C
- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response data:(nullable NSData *)data error:(NSError *_Nullable *_Nullable)error;Swift
func validate(_ response: HTTPURLResponse?, data: Data?) throwsParameters
responseThe response to be validated.
dataThe data associated with the response.
errorThe error that occurred while attempting to validate the response.
Return Value
YESif the response is valid, otherwiseNO.
View on GitHub
Install in Dash
LCHTTPResponseSerializer Class Reference