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.

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

acceptableStatusCodes

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.

@property (nonatomic, strong) NSIndexSet *acceptableStatusCodes

Declared In

AFURLResponseSerialization.h

stringEncoding

The string encoding used to serialize parameters.

@property (nonatomic, assign) NSStringEncoding stringEncoding

Declared In

AFURLResponseSerialization.h

Class Methods

serializer

Creates and returns a serializer with default configuration.

+ (instancetype)serializer

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