commit | author | age
|
6e1425
|
1 |
// AFHTTPSessionManager.h |
633752
|
2 |
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) |
6e1425
|
3 |
// |
H |
4 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
5 |
// of this software and associated documentation files (the "Software"), to deal |
|
6 |
// in the Software without restriction, including without limitation the rights |
|
7 |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
8 |
// copies of the Software, and to permit persons to whom the Software is |
|
9 |
// furnished to do so, subject to the following conditions: |
|
10 |
// |
|
11 |
// The above copyright notice and this permission notice shall be included in |
|
12 |
// all copies or substantial portions of the Software. |
|
13 |
// |
|
14 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
15 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
16 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
17 |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
18 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
19 |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
20 |
// THE SOFTWARE. |
|
21 |
|
|
22 |
#import <Foundation/Foundation.h> |
|
23 |
#if !TARGET_OS_WATCH |
|
24 |
#import <SystemConfiguration/SystemConfiguration.h> |
|
25 |
#endif |
633752
|
26 |
#import <TargetConditionals.h> |
6e1425
|
27 |
|
633752
|
28 |
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV |
6e1425
|
29 |
#import <MobileCoreServices/MobileCoreServices.h> |
H |
30 |
#else |
|
31 |
#import <CoreServices/CoreServices.h> |
|
32 |
#endif |
|
33 |
|
|
34 |
#import "AFURLSessionManager.h" |
|
35 |
|
|
36 |
/** |
|
37 |
`AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. |
|
38 |
|
|
39 |
## Subclassing Notes |
|
40 |
|
|
41 |
Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. |
|
42 |
|
|
43 |
For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. |
|
44 |
|
|
45 |
## Methods to Override |
|
46 |
|
633752
|
47 |
To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:`. |
6e1425
|
48 |
|
H |
49 |
## Serialization |
|
50 |
|
|
51 |
Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<AFURLRequestSerialization>`. |
|
52 |
|
|
53 |
Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<AFURLResponseSerialization>` |
|
54 |
|
|
55 |
## URL Construction Using Relative Paths |
|
56 |
|
|
57 |
For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. |
|
58 |
|
|
59 |
Below are a few examples of how `baseURL` and relative paths interact: |
|
60 |
|
|
61 |
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; |
|
62 |
[NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo |
|
63 |
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz |
|
64 |
[NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo |
|
65 |
[NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo |
|
66 |
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ |
|
67 |
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ |
|
68 |
|
|
69 |
Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. |
|
70 |
|
|
71 |
@warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. |
|
72 |
*/ |
|
73 |
|
|
74 |
NS_ASSUME_NONNULL_BEGIN |
|
75 |
|
|
76 |
@interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying> |
|
77 |
|
|
78 |
/** |
|
79 |
The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. |
|
80 |
*/ |
|
81 |
@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; |
|
82 |
|
|
83 |
/** |
|
84 |
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 of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. |
|
85 |
|
|
86 |
@warning `requestSerializer` must not be `nil`. |
|
87 |
*/ |
|
88 |
@property (nonatomic, strong) AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer; |
|
89 |
|
|
90 |
/** |
|
91 |
Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. |
|
92 |
|
|
93 |
@warning `responseSerializer` must not be `nil`. |
|
94 |
*/ |
|
95 |
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer; |
633752
|
96 |
|
L |
97 |
///------------------------------- |
|
98 |
/// @name Managing Security Policy |
|
99 |
///------------------------------- |
|
100 |
|
|
101 |
/** |
|
102 |
The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. A security policy configured with `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate` can 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 an `Invalid Security Policy` exception. |
|
103 |
*/ |
|
104 |
@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; |
6e1425
|
105 |
|
H |
106 |
///--------------------- |
|
107 |
/// @name Initialization |
|
108 |
///--------------------- |
|
109 |
|
|
110 |
/** |
|
111 |
Creates and returns an `AFHTTPSessionManager` object. |
|
112 |
*/ |
|
113 |
+ (instancetype)manager; |
|
114 |
|
|
115 |
/** |
|
116 |
Initializes an `AFHTTPSessionManager` object with the specified base URL. |
|
117 |
|
|
118 |
@param url The base URL for the HTTP client. |
|
119 |
|
|
120 |
@return The newly-initialized HTTP client |
|
121 |
*/ |
|
122 |
- (instancetype)initWithBaseURL:(nullable NSURL *)url; |
|
123 |
|
|
124 |
/** |
|
125 |
Initializes an `AFHTTPSessionManager` object with the specified base URL. |
|
126 |
|
|
127 |
This is the designated initializer. |
|
128 |
|
|
129 |
@param url The base URL for the HTTP client. |
|
130 |
@param configuration The configuration used to create the managed session. |
|
131 |
|
|
132 |
@return The newly-initialized HTTP client |
|
133 |
*/ |
|
134 |
- (instancetype)initWithBaseURL:(nullable NSURL *)url |
|
135 |
sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; |
|
136 |
|
|
137 |
///--------------------------- |
|
138 |
/// @name Making HTTP Requests |
|
139 |
///--------------------------- |
|
140 |
|
|
141 |
/** |
|
142 |
Creates and runs an `NSURLSessionDataTask` with a `GET` request. |
|
143 |
|
|
144 |
@param URLString The URL string used to create the request URL. |
|
145 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
146 |
@param success A 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. |
|
147 |
@param failure A 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. |
|
148 |
|
|
149 |
@see -dataTaskWithRequest:completionHandler: |
|
150 |
*/ |
|
151 |
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString |
|
152 |
parameters:(nullable id)parameters |
633752
|
153 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
L |
154 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
155 |
|
|
156 |
|
|
157 |
/** |
|
158 |
Creates and runs an `NSURLSessionDataTask` with a `GET` request. |
|
159 |
|
|
160 |
@param URLString The URL string used to create the request URL. |
|
161 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
162 |
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. |
|
163 |
@param success A 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. |
|
164 |
@param failure A 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. |
|
165 |
|
|
166 |
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: |
|
167 |
*/ |
|
168 |
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString |
|
169 |
parameters:(nullable id)parameters |
|
170 |
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress |
|
171 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
172 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
173 |
|
|
174 |
/** |
|
175 |
Creates and runs an `NSURLSessionDataTask` with a `GET` request. |
|
176 |
|
|
177 |
@param URLString The URL string used to create the request URL. |
|
178 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
179 |
@param headers The headers appended to the default headers for this request. |
|
180 |
@param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. |
|
181 |
@param success A 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. |
|
182 |
@param failure A 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. |
|
183 |
|
|
184 |
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: |
|
185 |
*/ |
|
186 |
- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString |
|
187 |
parameters:(nullable id)parameters |
|
188 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
189 |
progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress |
|
190 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
191 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
192 |
|
H |
193 |
/** |
|
194 |
Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. |
|
195 |
|
|
196 |
@param URLString The URL string used to create the request URL. |
|
197 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
198 |
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. |
|
199 |
@param failure A 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. |
|
200 |
|
|
201 |
@see -dataTaskWithRequest:completionHandler: |
|
202 |
*/ |
|
203 |
- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString |
|
204 |
parameters:(nullable id)parameters |
|
205 |
success:(nullable void (^)(NSURLSessionDataTask *task))success |
633752
|
206 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
L |
207 |
|
|
208 |
/** |
|
209 |
Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. |
|
210 |
|
|
211 |
@param URLString The URL string used to create the request URL. |
|
212 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
213 |
@param headers The headers appended to the default headers for this request. |
|
214 |
@param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. |
|
215 |
@param failure A 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. |
|
216 |
|
|
217 |
@see -dataTaskWithRequest:completionHandler: |
|
218 |
*/ |
|
219 |
- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString |
|
220 |
parameters:(nullable id)parameters |
|
221 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
222 |
success:(nullable void (^)(NSURLSessionDataTask *task))success |
|
223 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
224 |
|
H |
225 |
/** |
|
226 |
Creates and runs an `NSURLSessionDataTask` with a `POST` request. |
|
227 |
|
|
228 |
@param URLString The URL string used to create the request URL. |
|
229 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
230 |
@param success A 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. |
|
231 |
@param failure A 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. |
|
232 |
|
|
233 |
@see -dataTaskWithRequest:completionHandler: |
|
234 |
*/ |
|
235 |
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString |
|
236 |
parameters:(nullable id)parameters |
633752
|
237 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
L |
238 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
239 |
|
|
240 |
/** |
|
241 |
Creates and runs an `NSURLSessionDataTask` with a `POST` request. |
|
242 |
|
|
243 |
@param URLString The URL string used to create the request URL. |
|
244 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
245 |
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. |
|
246 |
@param success A 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. |
|
247 |
@param failure A 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. |
|
248 |
|
|
249 |
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: |
|
250 |
*/ |
|
251 |
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString |
|
252 |
parameters:(nullable id)parameters |
|
253 |
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress |
|
254 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
255 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
256 |
|
|
257 |
/** |
|
258 |
Creates and runs an `NSURLSessionDataTask` with a `POST` request. |
|
259 |
|
|
260 |
@param URLString The URL string used to create the request URL. |
|
261 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
262 |
@param headers The headers appended to the default headers for this request. |
|
263 |
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. |
|
264 |
@param success A 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. |
|
265 |
@param failure A 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. |
|
266 |
|
|
267 |
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: |
|
268 |
*/ |
|
269 |
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString |
|
270 |
parameters:(nullable id)parameters |
|
271 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
272 |
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress |
|
273 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
274 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
275 |
|
H |
276 |
/** |
|
277 |
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. |
|
278 |
|
|
279 |
@param URLString The URL string used to create the request URL. |
|
280 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
281 |
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. |
|
282 |
@param success A 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. |
|
283 |
@param failure A 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. |
|
284 |
|
|
285 |
@see -dataTaskWithRequest:completionHandler: |
|
286 |
*/ |
|
287 |
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString |
|
288 |
parameters:(nullable id)parameters |
|
289 |
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block |
633752
|
290 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
L |
291 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
292 |
|
|
293 |
/** |
|
294 |
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. |
|
295 |
|
|
296 |
@param URLString The URL string used to create the request URL. |
|
297 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
298 |
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. |
|
299 |
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. |
|
300 |
@param success A 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. |
|
301 |
@param failure A 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. |
|
302 |
|
|
303 |
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: |
|
304 |
*/ |
|
305 |
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString |
|
306 |
parameters:(nullable id)parameters |
|
307 |
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block |
|
308 |
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress |
|
309 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
310 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
311 |
/** |
|
312 |
Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. |
|
313 |
|
|
314 |
@param URLString The URL string used to create the request URL. |
|
315 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
316 |
@param headers The headers appended to the default headers for this request. |
|
317 |
@param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. |
|
318 |
@param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. |
|
319 |
@param success A 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. |
|
320 |
@param failure A 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. |
|
321 |
|
|
322 |
@see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: |
|
323 |
*/ |
|
324 |
- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString |
|
325 |
parameters:(nullable id)parameters |
|
326 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
327 |
constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block |
|
328 |
progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress |
|
329 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
330 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
331 |
|
H |
332 |
/** |
|
333 |
Creates and runs an `NSURLSessionDataTask` with a `PUT` request. |
|
334 |
|
|
335 |
@param URLString The URL string used to create the request URL. |
|
336 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
337 |
@param success A 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. |
|
338 |
@param failure A 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. |
|
339 |
|
|
340 |
@see -dataTaskWithRequest:completionHandler: |
|
341 |
*/ |
|
342 |
- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString |
|
343 |
parameters:(nullable id)parameters |
633752
|
344 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
L |
345 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
346 |
|
|
347 |
/** |
|
348 |
Creates and runs an `NSURLSessionDataTask` with a `PUT` request. |
|
349 |
|
|
350 |
@param URLString The URL string used to create the request URL. |
|
351 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
352 |
@param headers The headers appended to the default headers for this request. |
|
353 |
@param success A 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. |
|
354 |
@param failure A 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. |
|
355 |
|
|
356 |
@see -dataTaskWithRequest:completionHandler: |
|
357 |
*/ |
|
358 |
- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString |
|
359 |
parameters:(nullable id)parameters |
|
360 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
361 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
362 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
363 |
|
H |
364 |
/** |
|
365 |
Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. |
|
366 |
|
|
367 |
@param URLString The URL string used to create the request URL. |
|
368 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
369 |
@param success A 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. |
|
370 |
@param failure A 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. |
|
371 |
|
|
372 |
@see -dataTaskWithRequest:completionHandler: |
|
373 |
*/ |
|
374 |
- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString |
|
375 |
parameters:(nullable id)parameters |
633752
|
376 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
L |
377 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
378 |
|
|
379 |
/** |
|
380 |
Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. |
|
381 |
|
|
382 |
@param URLString The URL string used to create the request URL. |
|
383 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
384 |
@param headers The headers appended to the default headers for this request. |
|
385 |
@param success A 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. |
|
386 |
@param failure A 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. |
|
387 |
|
|
388 |
@see -dataTaskWithRequest:completionHandler: |
|
389 |
*/ |
|
390 |
- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString |
|
391 |
parameters:(nullable id)parameters |
|
392 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
393 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
394 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
395 |
|
H |
396 |
/** |
|
397 |
Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. |
|
398 |
|
|
399 |
@param URLString The URL string used to create the request URL. |
|
400 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
401 |
@param success A 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. |
|
402 |
@param failure A 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. |
|
403 |
|
|
404 |
@see -dataTaskWithRequest:completionHandler: |
|
405 |
*/ |
|
406 |
- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString |
|
407 |
parameters:(nullable id)parameters |
633752
|
408 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
L |
409 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; |
|
410 |
|
|
411 |
/** |
|
412 |
Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. |
|
413 |
|
|
414 |
@param URLString The URL string used to create the request URL. |
|
415 |
@param parameters The parameters to be encoded according to the client request serializer. |
|
416 |
@param headers The headers appended to the default headers for this request. |
|
417 |
@param success A 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. |
|
418 |
@param failure A 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. |
|
419 |
|
|
420 |
@see -dataTaskWithRequest:completionHandler: |
|
421 |
*/ |
|
422 |
- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString |
|
423 |
parameters:(nullable id)parameters |
|
424 |
headers:(nullable NSDictionary <NSString *, NSString *> *)headers |
|
425 |
success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success |
|
426 |
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; |
6e1425
|
427 |
|
H |
428 |
@end |
|
429 |
|
|
430 |
NS_ASSUME_NONNULL_END |