AFHTTPResponseSerializer Class Reference
Inherits from | NSObject |
Conforms to | AFURLResponseSerialization |
Declared in | AFURLResponseSerialization.h AFURLResponseSerialization.m |
Overview
AFHTTPResponseSerializer
conforms to the AFURLRequestSerialization
& AFURLResponseSerialization
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 AFHTTPResponseSerializer
in order to ensure consistent default behavior.
Tasks
Other Methods
-
stringEncoding
property -
+ serializer
Configuring Response Serialization
-
acceptableStatusCodes
property -
acceptableContentTypes
property -
– validateResponse:data:error:
Other Methods
Properties
acceptableContentTypes
The acceptable MIME types for responses. When non-nil
, responses with a Content-Type
with MIME types that do not intersect with the set will result in an error during validation.
@property (nonatomic, strong) NSSet *acceptableContentTypes
Declared In
AFURLResponseSerialization.h
Instance Methods
responseObjectForResponse:data:error:
- (id)responseObjectForResponse:(NSURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error
Declared In
AFURLResponseSerialization.h
validateResponse:data:error:
Validates the specified response and data.
- (BOOL)validateResponse:(NSHTTPURLResponse *)response data:(NSData *)data error:(NSError *__autoreleasing *)error
Parameters
- response
The response to be validated.
- data
The data associated with the response.
- error
The error that occurred while attempting to validate the response.
Return Value
YES
if the response is valid, otherwise NO
.
Discussion
In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
Declared In
AFURLResponseSerialization.h