FWHTTPResponseSerializer
@interface FWHTTPResponseSerializer : NSObject <FWURLResponseSerialization>
FWHTTPResponseSerializer conforms to the FWURLRequestSerialization & FWURLResponseSerialization 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 FWHTTPResponseSerializer in order to ensure consistent default behavior.
-
Undocumented
Declaration
Objective-C
- (instancetype)init; -
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; -
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; -
Sets a user info to be used for the specified response.
Declaration
Objective-C
- (void)setUserInfo:(nullable NSDictionary *)userInfo forResponse:(nullable NSURLResponse *)response; -
Returns the user info of the specified response.
Declaration
Objective-C
- (nullable NSDictionary *)userInfoForResponse: (nullable NSURLResponse *)response; -
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 *__autoreleasing _Nullable *_Nullable)error;Parameters
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.
FWHTTPResponseSerializer Class Reference