FWHTTPSessionManager
@interface FWHTTPSessionManager
: FWURLSessionManager <NSSecureCoding, NSCopying>
FWHTTPSessionManager
-
The URL used to construct requests from relative paths in methods like
requestWithMethod:URLString:parameters:, and theGET/POST/ et al. convenience methods.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) NSURL *baseURL; -
Requests created with
requestWithMethod:URLString:parameters:&multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance ofFWHTTPRequestSerializer, which serializes query string parameters forGET,HEAD, andDELETErequests, or otherwise URL-form-encodes HTTP message bodies.Warning
requestSerializermust not benil.Declaration
Objective-C
@property (nonatomic, strong) FWHTTPRequestSerializer<FWURLRequestSerialization> *_Nonnull requestSerializer; -
Responses sent from the server in data tasks created with
dataTaskWithRequest:success:failure:and run using theGET/POST/ et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance ofFWJSONResponseSerializer.Warning
responseSerializermust not benil.Declaration
Objective-C
@property (nonatomic, strong) FWHTTPResponseSerializer<FWURLResponseSerialization> *_Nonnull responseSerializer;
-
The security policy used by created session to evaluate server trust for secure connections.
FWURLSessionManageruses thedefaultPolicyunless otherwise specified. A security policy configured withFWSSLPinningModePublicKeyorFWSSLPinningModeCertificatecan only be applied on a session manager initialized with a secure base URL (i.e. https). Applying a security policy with pinning enabled on an insecure session manager throws anInvalid Security Policyexception.Declaration
Objective-C
@property (nonatomic, strong) FWSecurityPolicy *_Nonnull securityPolicy;
-
Creates and returns an
FWHTTPSessionManagerobject.Declaration
Objective-C
+ (nonnull instancetype)manager; -
Initializes an
FWHTTPSessionManagerobject with the specified base URL.Declaration
Objective-C
- (nonnull instancetype)initWithBaseURL:(nullable NSURL *)url;Parameters
urlThe base URL for the HTTP client.
Return Value
The newly-initialized HTTP client
-
Initializes an
FWHTTPSessionManagerobject with the specified base URL.This is the designated initializer.
Declaration
Objective-C
- (nonnull instancetype)initWithBaseURL:(nullable NSURL *)url sessionConfiguration: (nullable NSURLSessionConfiguration *)configuration;Parameters
urlThe base URL for the HTTP client.
configurationThe configuration used to create the managed session.
Return Value
The newly-initialized HTTP client
-
Creates and runs an
NSURLSessionDataTaskwith aGETrequest.See
-dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) GET:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *)headers progress: (nullable void (^)(NSProgress *_Nonnull __strong))downloadProgress success:(nullable void (^)(NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)(NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
downloadProgressA block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
Creates and runs an
NSURLSessionDataTaskwith aHEADrequest.See
-dataTaskWithRequest:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) HEAD:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *)headers success: (nullable void (^)(NSURLSessionDataTask *_Nonnull __strong))success failure:(nullable void (^)(NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
successA block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
Creates and runs an
NSURLSessionDataTaskwith aPOSTrequest.See
-dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) POST:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *)headers progress:(nullable void (^)(NSProgress *_Nonnull __strong))uploadProgress success:(nullable void (^)(NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)(NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
uploadProgressA block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
Creates and runs an
NSURLSessionDataTaskwith a multipartPOSTrequest.See
-dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) POST:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *) headers constructingBodyWithBlock: (nullable void (^)(id<FWMultipartFormData> _Nonnull __strong))block progress:(nullable void (^)(NSProgress *_Nonnull __strong)) uploadProgress success:(nullable void (^)( NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)( NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
blockA block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the
FWMultipartFormDataprotocol.uploadProgressA block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
Creates and runs an
NSURLSessionDataTaskwith aPUTrequest.See
-dataTaskWithRequest:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) PUT:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *)headers success:(nullable void (^)(NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)(NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
Creates and runs an
NSURLSessionDataTaskwith aPATCHrequest.See
-dataTaskWithRequest:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) PATCH:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *)headers success:(nullable void (^)(NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)(NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
Creates and runs an
NSURLSessionDataTaskwith aDELETErequest.See
-dataTaskWithRequest:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) DELETE:(nonnull NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary<NSString *, NSString *> *)headers success:(nullable void (^)(NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)(NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
-
-dataTaskWithHTTPMethod:URLString: parameters: headers: uploadProgress: downloadProgress: success: failure: Creates an
NSURLSessionDataTaskwith a customHTTPMethodrequest.See
-dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
Declaration
Objective-C
- (nullable NSURLSessionDataTask *) dataTaskWithHTTPMethod:(nonnull NSString *)method URLString:(nonnull NSString *)URLString parameters:(nullable id)parameters headers: (nullable NSDictionary<NSString *, NSString *> *)headers uploadProgress: (nullable void (^)(NSProgress *_Nonnull __strong))uploadProgress downloadProgress: (nullable void (^)(NSProgress *_Nonnull __strong))downloadProgress success:(nullable void (^)( NSURLSessionDataTask *_Nonnull __strong, id _Nullable __strong))success failure:(nullable void (^)( NSURLSessionDataTask *_Nullable __strong, NSError *_Nonnull __strong))failure;Parameters
methodThe HTTPMethod string used to create the request.
URLStringThe URL string used to create the request URL.
parametersThe parameters to be encoded according to the client request serializer.
headersThe headers appended to the default headers for this request.
uploadProgressA block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
downloadProgressA block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
successA block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
failureA block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
FWHTTPSessionManager Class Reference