Skip to content

Commit 68c4964

Browse files
committed
Update readme
1 parent b09d84d commit 68c4964

21 files changed

Lines changed: 5018 additions & 1 deletion

‎AFNetworking/AFHTTPClient.h‎

Lines changed: 595 additions & 0 deletions
Large diffs are not rendered by default.

‎AFNetworking/AFHTTPClient.m‎

Lines changed: 1266 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// AFHTTPRequestOperation.h
2+
//
3+
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
#import <Foundation/Foundation.h>
24+
#import "AFURLConnectionOperation.h"
25+
26+
/**
27+
`AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
28+
*/
29+
@interface AFHTTPRequestOperation : AFURLConnectionOperation
30+
31+
///----------------------------------------------
32+
/// @name Getting HTTP URL Connection Information
33+
///----------------------------------------------
34+
35+
/**
36+
The last HTTP response received by the operation's connection.
37+
*/
38+
@property (readonly, nonatomic, strong) NSHTTPURLResponse *response;
39+
40+
///----------------------------------------------------------
41+
/// @name Managing And Checking For Acceptable HTTP Responses
42+
///----------------------------------------------------------
43+
44+
/**
45+
A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`.
46+
*/
47+
@property (nonatomic, readonly) BOOL hasAcceptableStatusCode;
48+
49+
/**
50+
A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`.
51+
*/
52+
@property (nonatomic, readonly) BOOL hasAcceptableContentType;
53+
54+
/**
55+
The callback dispatch queue on success. If `NULL` (default), the main queue is used.
56+
*/
57+
@property (nonatomic, assign) dispatch_queue_t successCallbackQueue;
58+
59+
/**
60+
The callback dispatch queue on failure. If `NULL` (default), the main queue is used.
61+
*/
62+
@property (nonatomic, assign) dispatch_queue_t failureCallbackQueue;
63+
64+
///------------------------------------------------------------
65+
/// @name Managing Acceptable HTTP Status Codes & Content Types
66+
///------------------------------------------------------------
67+
68+
/**
69+
Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
70+
71+
By default, this is the range 200 to 299, inclusive.
72+
*/
73+
+ (NSIndexSet *)acceptableStatusCodes;
74+
75+
/**
76+
Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants.
77+
78+
@param statusCodes The status codes to be added to the set of acceptable HTTP status codes
79+
*/
80+
+ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes;
81+
82+
/**
83+
Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
84+
85+
By default, this is `nil`.
86+
*/
87+
+ (NSSet *)acceptableContentTypes;
88+
89+
/**
90+
Adds content types to the set of acceptable MIME types returned by `+acceptableContentTypes` in subsequent calls by this class and its descendants.
91+
92+
@param contentTypes The content types to be added to the set of acceptable MIME types
93+
*/
94+
+ (void)addAcceptableContentTypes:(NSSet *)contentTypes;
95+
96+
97+
///-----------------------------------------------------
98+
/// @name Determining Whether A Request Can Be Processed
99+
///-----------------------------------------------------
100+
101+
/**
102+
A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`.
103+
104+
@param urlRequest The request that is determined to be supported or not supported for this class.
105+
*/
106+
+ (BOOL)canProcessRequest:(NSURLRequest *)urlRequest;
107+
108+
///-----------------------------------------------------------
109+
/// @name Setting Completion Block Success / Failure Callbacks
110+
///-----------------------------------------------------------
111+
112+
/**
113+
Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed.
114+
115+
@param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request.
116+
@param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request.
117+
118+
@discussion This method should be overridden in subclasses in order to specify the response object passed into the success block.
119+
*/
120+
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
121+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
122+
123+
@end
124+
125+
///----------------
126+
/// @name Functions
127+
///----------------
128+
129+
/**
130+
Returns a set of MIME types detected in an HTTP `Accept` or `Content-Type` header.
131+
*/
132+
extern NSSet * AFContentTypesFromHTTPHeader(NSString *string);
133+

0 commit comments

Comments
 (0)