afmotion 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/AFMotion.gemspec +1 -1
  2. data/Gemfile.lock +1 -1
  3. data/lib/afmotion/version.rb +1 -1
  4. metadata +3 -67
  5. data/examples/AppDotNet/.gitignore +0 -13
  6. data/examples/AppDotNet/Gemfile +0 -4
  7. data/examples/AppDotNet/Gemfile.lock +0 -48
  8. data/examples/AppDotNet/Rakefile +0 -10
  9. data/examples/AppDotNet/app/app_delegate.rb +0 -28
  10. data/examples/AppDotNet/app/global_timeline_view_controller.rb +0 -84
  11. data/examples/AppDotNet/app/post.rb +0 -23
  12. data/examples/AppDotNet/app/post_table_view_cell.rb +0 -44
  13. data/examples/AppDotNet/app/user.rb +0 -9
  14. data/examples/AppDotNet/resources/profile-image-placeholder.png +0 -0
  15. data/examples/AppDotNet/resources/profile-image-placeholder@2x.png +0 -0
  16. data/examples/AppDotNet/spec/main_spec.rb +0 -9
  17. data/examples/AppDotNet/vendor/Podfile.lock +0 -11
  18. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking.podspec +0 -28
  19. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -574
  20. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1187
  21. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  22. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -341
  23. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -108
  24. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -237
  25. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  26. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -136
  27. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  28. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -131
  29. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -44
  30. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  31. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -145
  32. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -295
  33. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -652
  34. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  35. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -169
  36. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  37. data/examples/AppDotNet/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -180
  38. data/examples/AppDotNet/vendor/Pods/AFNetworking/LICENSE +0 -19
  39. data/examples/AppDotNet/vendor/Pods/AFNetworking/README.md +0 -179
  40. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -574
  41. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  42. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -108
  43. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  44. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  45. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -44
  46. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  47. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -295
  48. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  49. data/examples/AppDotNet/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  50. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -574
  51. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  52. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -108
  53. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  54. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  55. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -44
  56. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  57. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -295
  58. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  59. data/examples/AppDotNet/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  60. data/examples/AppDotNet/vendor/Pods/Pods-Acknowledgements.markdown +0 -26
  61. data/examples/AppDotNet/vendor/Pods/Pods-Acknowledgements.plist +0 -56
  62. data/examples/AppDotNet/vendor/Pods/Pods-prefix.pch +0 -12
  63. data/examples/AppDotNet/vendor/Pods/Pods-resources.sh +0 -19
  64. data/examples/AppDotNet/vendor/Pods/Pods.bridgesupport +0 -617
  65. data/examples/AppDotNet/vendor/Pods/Pods.xcconfig +0 -7
  66. data/examples/AppDotNet/vendor/Pods/Pods.xcodeproj/project.pbxproj +0 -998
  67. data/examples/AppDotNet/vendor/Pods/PodsDummy_Pods.m +0 -4
  68. data/pkg/afmotion-0.0.1.gem +0 -0
@@ -1,19 +0,0 @@
1
- Copyright (c) 2011 Gowalla (http://gowalla.com/)
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
@@ -1,179 +0,0 @@
1
- <img src="https://github.com/AFNetworking/AFNetworking/raw/gh-pages/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking" style="display:block; margin: 10px auto 30px auto;" class="center">
2
-
3
- AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of [NSURLConnection](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html), [NSOperation](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html), and other familiar Foundation technologies. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. For example, here's how easy it is to get JSON from a URL:
4
-
5
- ``` objective-c
6
- NSURL *url = [NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"];
7
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
8
- AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
9
- NSLog(@"App.net Global Stream: %@", JSON);
10
- } failure:nil];
11
- [operation start];
12
- ```
13
-
14
- Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
15
-
16
- Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!
17
-
18
- ## How To Get Started
19
-
20
- - [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/zipball/master) and try out the included Mac and iPhone example apps
21
- - Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles in the wiki](https://github.com/AFNetworking/AFNetworking/wiki)
22
- - Check out the [complete documentation](http://afnetworking.github.com/AFNetworking/) for a comprehensive look at the APIs available in AFNetworking
23
- - Watch the [NSScreencast episode about AFNetworking](http://nsscreencast.com/episodes/6-afnetworking) for a quick introduction to how to use it in your application
24
- - Questions? [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking) is the best place to find answers
25
-
26
- ## Overview
27
-
28
- AFNetworking is architected to be as small and modular as possible, in order to make it simple to use and extend.
29
-
30
- <table>
31
- <tr><th colspan="2" style="text-align:center;">Core</th></tr>
32
- <tr>
33
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFURLConnectionOperation.html">AFURLConnectionOperation</a></td>
34
- <td>An <tt>NSOperation</tt> that implements the <tt>NSURLConnection</tt> delegate methods.</td>
35
- </tr>
36
-
37
- <tr><th colspan="2" style="text-align:center;">HTTP Requests</th></tr>
38
-
39
- <tr>
40
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFHTTPRequestOperation.html">AFHTTPRequestOperation</a></td>
41
- <td>A subclass of <tt>AFURLConnectionOperation</tt> 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.</td>
42
- </tr>
43
- <tr>
44
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFJSONRequestOperation.html">AFJSONRequestOperation</a></td>
45
- <td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and working with JSON response data.</td>
46
- </tr>
47
- <tr>
48
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFXMLRequestOperation.html">AFXMLRequestOperation</a></td>
49
- <td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and working with XML response data.</td>
50
- </tr>
51
- <tr>
52
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFPropertyListRequestOperation.html">AFPropertyListRequestOperation</a></td>
53
- <td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and deserializing objects with <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PropertyLists/index.html">property list</a> response data.</td>
54
- </tr>
55
-
56
- <tr><th colspan="2" style="text-align:center;">HTTP Client</th></tr>
57
- <tr>
58
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFHTTPClient.html">AFHTTPClient</a></td>
59
- <td>
60
- Captures the common patterns of communicating with an web application over HTTP, including:
61
-
62
- <ul>
63
- <li>Making requests from relative paths of a base URL</li>
64
- <li>Setting HTTP headers to be added automatically to requests</li>
65
- <li>Authenticating requests with HTTP Basic credentials or an OAuth token</li>
66
- <li>Managing an <tt>NSOperationQueue</tt> for requests made by the client</li>
67
- <li>Generating query strings or HTTP bodies from an <tt>NSDictionary</tt></li>
68
- <li>Constructing multipart form requests</li>
69
- <li>Automatically parsing HTTP response data into its corresponding object representation</li>
70
- <li>Monitoring and responding to changes in network reachability</li>
71
- </ul>
72
- </td>
73
- </tr>
74
-
75
- <tr><th colspan="2" style="text-align:center;">Images</th></tr>
76
- <tr>
77
- <td><a href="http://afnetworking.github.com/AFNetworking/Classes/AFImageRequestOperation.html">AFImageRequestOperation</a></td>
78
- <td>A subclass of <tt>AFHTTPRequestOperation</tt> for downloading and processing images.</td>
79
- </tr>
80
- <tr>
81
- <td><a href="http://afnetworking.github.com/AFNetworking/Categories/UIImageView+AFNetworking.html">UIImageView+AFNetworking</a></td>
82
- <td>Adds methods to <tt>UIImageView</tt> for loading remote images asynchronously from a URL.</td>
83
- </tr>
84
- </table>
85
-
86
- ## Example Usage
87
-
88
- ### XML Request
89
-
90
- ``` objective-c
91
- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.flickr.com/services/rest/?method=flickr.groups.browse&api_key=b6300e17ad3c506e706cb0072175d047&cat_id=34427469792%40N01&format=rest"]];
92
- AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
93
- XMLParser.delegate = self;
94
- [XMLParser parse];
95
- } failure:nil];
96
- [operation start];
97
- ```
98
-
99
- ### Image Request
100
-
101
- ``` objective-c
102
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
103
- [imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
104
- ```
105
-
106
- ### API Client Request
107
-
108
- ``` objective-c
109
- // AFAppDotNetAPIClient is a subclass of AFHTTPClient, which defines the base URL and default HTTP headers for NSURLRequests it creates
110
- [[AFAppDotNetAPIClient sharedClient] getPath:@"stream/0/posts/stream/global" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) {
111
- NSLog(@"App.net Global Stream: %@", JSON);
112
- } failure:nil];
113
- ```
114
-
115
- ### File Upload with Progress Callback
116
-
117
- ``` objective-c
118
- NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"];
119
- AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
120
- NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5);
121
- NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
122
- [formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
123
- }];
124
-
125
- AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
126
- [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
127
- NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
128
- }];
129
- [operation start];
130
- ```
131
-
132
- ### Streaming Request
133
-
134
- ``` objective-c
135
- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:8080/encode"]];
136
-
137
- AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
138
- operation.inputStream = [NSInputStream inputStreamWithFileAtPath:[[NSBundle mainBundle] pathForResource:@"large-image" ofType:@"tiff"]];
139
- operation.outputStream = [NSOutputStream outputStreamToMemory];
140
- [operation start];
141
- ```
142
-
143
- ## Requirements
144
-
145
- AFNetworking 1.0 and higher requires either [iOS 5.0](http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html) and above, or [Mac OS 10.7](http://developer.apple.com/library/mac/#releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW7) ([64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)) and above.
146
-
147
- For compatibility with iOS 4.3, use the latest 0.10.x release.
148
-
149
- ### ARC
150
-
151
- AFNetworking uses ARC as of its 1.0 release.
152
-
153
- If you are using AFNetworking 1.0 in your non-arc project, you will need to set a `-fobjc-arc` compiler flag on all of the AFNetworking source files. Conversely, if you are adding a pre-1.0 version of AFNetworking, you will need to set a `-fno-objc-arc` compiler flag.
154
-
155
- To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all AFNetworking source files, press Enter, insert `-fobjc-arc` or `-fno-objc-arc` and then "Done" to enable or disable ARC for AFNetworking.
156
-
157
- ## Credits
158
-
159
- AFNetworking was created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla).
160
-
161
- AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).
162
-
163
- And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).
164
-
165
- ## Contact
166
-
167
- Follow AFNetworking on Twitter ([@AFNetworking](https://twitter.com/AFNetworking))
168
-
169
- ### Creators
170
-
171
- [Mattt Thompson](http://github.com/mattt)
172
- [@mattt](https://twitter.com/mattt)
173
-
174
- [Scott Raymond](http://github.com/sco)
175
- [@sco](https://twitter.com/sco)
176
-
177
- ## License
178
-
179
- AFNetworking is available under the MIT license. See the LICENSE file for more info.
@@ -1,574 +0,0 @@
1
- // AFHTTPClient.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
-
25
- /**
26
- `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations.
27
-
28
- ## Automatic Content Parsing
29
-
30
- Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`.
31
-
32
- ## Subclassing Notes
33
-
34
- In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application.
35
-
36
- ## Methods to Override
37
-
38
- To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
39
-
40
- To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`.
41
-
42
- ## Default Headers
43
-
44
- By default, `AFHTTPClient` sets the following HTTP headers:
45
-
46
- - `Accept-Encoding: gzip`
47
- - `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8`
48
- - `User-Agent: (generated user agent)`
49
-
50
- You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
51
-
52
- ## URL Construction Using Relative Paths
53
-
54
- Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact:
55
-
56
- NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
57
- [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
58
- [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
59
- [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
60
- [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
61
- [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
62
- [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
63
-
64
- Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
65
-
66
- ## NSCoding / NSCopying Conformance
67
-
68
- `AFHTTPClient` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
69
-
70
- - Archives and copies of HTTP clients will be initialized with an empty operation queue.
71
- - NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
72
- */
73
-
74
- #ifdef _SYSTEMCONFIGURATION_H
75
- typedef enum {
76
- AFNetworkReachabilityStatusUnknown = -1,
77
- AFNetworkReachabilityStatusNotReachable = 0,
78
- AFNetworkReachabilityStatusReachableViaWWAN = 1,
79
- AFNetworkReachabilityStatusReachableViaWiFi = 2,
80
- } AFNetworkReachabilityStatus;
81
- #else
82
- #warning "SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available."
83
- #endif
84
-
85
- #ifndef __UTTYPE__
86
- #warning "CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available."
87
- #endif
88
-
89
- typedef enum {
90
- AFFormURLParameterEncoding,
91
- AFJSONParameterEncoding,
92
- AFPropertyListParameterEncoding,
93
- } AFHTTPClientParameterEncoding;
94
-
95
- @class AFHTTPRequestOperation;
96
- @protocol AFMultipartFormData;
97
-
98
- @interface AFHTTPClient : NSObject <NSCoding, NSCopying>
99
-
100
- ///---------------------------------------
101
- /// @name Accessing HTTP Client Properties
102
- ///---------------------------------------
103
-
104
- /**
105
- The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
106
- */
107
- @property (readonly, nonatomic) NSURL *baseURL;
108
-
109
- /**
110
- The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
111
- */
112
- @property (nonatomic, assign) NSStringEncoding stringEncoding;
113
-
114
- /**
115
- The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default.
116
- */
117
- @property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
118
-
119
- /**
120
- The operation queue which manages operations enqueued by the HTTP client.
121
- */
122
- @property (readonly, nonatomic) NSOperationQueue *operationQueue;
123
-
124
- /**
125
- The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.
126
-
127
- @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
128
- */
129
- #ifdef _SYSTEMCONFIGURATION_H
130
- @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
131
- #endif
132
-
133
- ///---------------------------------------------
134
- /// @name Creating and Initializing HTTP Clients
135
- ///---------------------------------------------
136
-
137
- /**
138
- Creates and initializes an `AFHTTPClient` object with the specified base URL.
139
-
140
- @param url The base URL for the HTTP client. This argument must not be `nil`.
141
-
142
- @return The newly-initialized HTTP client
143
- */
144
- + (AFHTTPClient *)clientWithBaseURL:(NSURL *)url;
145
-
146
- /**
147
- Initializes an `AFHTTPClient` object with the specified base URL.
148
-
149
- @param url The base URL for the HTTP client. This argument must not be `nil`.
150
-
151
- @discussion This is the designated initializer.
152
-
153
- @return The newly-initialized HTTP client
154
- */
155
- - (id)initWithBaseURL:(NSURL *)url;
156
-
157
- ///-----------------------------------
158
- /// @name Managing Reachability Status
159
- ///-----------------------------------
160
-
161
- /**
162
- Sets a callback to be executed when the network availability of the `baseURL` host changes.
163
-
164
- @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
165
-
166
- @warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
167
- */
168
- #ifdef _SYSTEMCONFIGURATION_H
169
- - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
170
- #endif
171
-
172
- ///-------------------------------
173
- /// @name Managing HTTP Operations
174
- ///-------------------------------
175
-
176
- /**
177
- Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
178
-
179
- @param operationClass The subclass of `AFHTTPRequestOperation` to register
180
-
181
- @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
182
-
183
- @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list.
184
- */
185
- - (BOOL)registerHTTPOperationClass:(Class)operationClass;
186
-
187
- /**
188
- Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called.
189
-
190
- @param operationClass The subclass of `AFHTTPRequestOperation` to register
191
- */
192
- - (void)unregisterHTTPOperationClass:(Class)operationClass;
193
-
194
- ///----------------------------------
195
- /// @name Managing HTTP Header Values
196
- ///----------------------------------
197
-
198
- /**
199
- Returns the value for the HTTP headers set in request objects created by the HTTP client.
200
-
201
- @param header The HTTP header to return the default value for
202
-
203
- @return The default value for the HTTP header, or `nil` if unspecified
204
- */
205
- - (NSString *)defaultValueForHeader:(NSString *)header;
206
-
207
- /**
208
- Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
209
-
210
- @param header The HTTP header to set a default value for
211
- @param value The value set as default for the specified header, or `nil
212
- */
213
- - (void)setDefaultHeader:(NSString *)header value:(NSString *)value;
214
-
215
- /**
216
- Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
217
-
218
- @param username The HTTP basic auth username
219
- @param password The HTTP basic auth password
220
- */
221
- - (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password;
222
-
223
- /**
224
- Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
225
-
226
- @param token The authentication token
227
- */
228
- - (void)setAuthorizationHeaderWithToken:(NSString *)token;
229
-
230
- /**
231
- Clears any existing value for the "Authorization" HTTP header.
232
- */
233
- - (void)clearAuthorizationHeader;
234
-
235
- ///-------------------------------
236
- /// @name Creating Request Objects
237
- ///-------------------------------
238
-
239
- /**
240
- Creates an `NSMutableURLRequest` object with the specified HTTP method and path.
241
-
242
- If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
243
-
244
- @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
245
- @param path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL.
246
- @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
247
-
248
- @return An `NSMutableURLRequest` object
249
- */
250
- - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
251
- path:(NSString *)path
252
- parameters:(NSDictionary *)parameters;
253
-
254
- /**
255
- Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
256
-
257
- @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
258
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
259
- @param parameters The parameters to be encoded and set in the request HTTP body.
260
- @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. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values.
261
-
262
- @discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
263
-
264
- @return An `NSMutableURLRequest` object
265
- */
266
- - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
267
- path:(NSString *)path
268
- parameters:(NSDictionary *)parameters
269
- constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
270
-
271
- ///-------------------------------
272
- /// @name Creating HTTP Operations
273
- ///-------------------------------
274
-
275
- /**
276
- Creates an `AFHTTPRequestOperation`.
277
-
278
- In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`.
279
-
280
- @param urlRequest The request object to be loaded asynchronously during execution of the operation.
281
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
282
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
283
- */
284
- - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
285
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
286
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
287
-
288
- ///----------------------------------------
289
- /// @name Managing Enqueued HTTP Operations
290
- ///----------------------------------------
291
-
292
- /**
293
- Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
294
-
295
- @param operation The HTTP request operation to be enqueued.
296
- */
297
- - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
298
-
299
- /**
300
- Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
301
-
302
- @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled.
303
- @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL.
304
-
305
- @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property.
306
- */
307
- - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
308
-
309
- ///---------------------------------------
310
- /// @name Batching HTTP Request Operations
311
- ///---------------------------------------
312
-
313
- /**
314
- Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
315
-
316
- @param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
317
- @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
318
- @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
319
-
320
- @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
321
- */
322
- - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
323
- progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
324
- completionBlock:(void (^)(NSArray *operations))completionBlock;
325
-
326
- /**
327
- Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
328
-
329
- @param operations The request operations used to be batched and enqueued.
330
- @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
331
- @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
332
- */
333
- - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
334
- progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
335
- completionBlock:(void (^)(NSArray *operations))completionBlock;
336
-
337
- ///---------------------------
338
- /// @name Making HTTP Requests
339
- ///---------------------------
340
-
341
- /**
342
- Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
343
-
344
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
345
- @param parameters The parameters to be encoded and appended as the query string for the request URL.
346
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
347
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
348
-
349
- @see -HTTPRequestOperationWithRequest:success:failure:
350
- */
351
- - (void)getPath:(NSString *)path
352
- parameters:(NSDictionary *)parameters
353
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
354
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
355
-
356
- /**
357
- Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
358
-
359
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
360
- @param parameters The parameters to be encoded and set in the request HTTP body.
361
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
362
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
363
-
364
- @see -HTTPRequestOperationWithRequest:success:failure:
365
- */
366
- - (void)postPath:(NSString *)path
367
- parameters:(NSDictionary *)parameters
368
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
369
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
370
-
371
- /**
372
- Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
373
-
374
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
375
- @param parameters The parameters to be encoded and set in the request HTTP body.
376
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
377
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
378
-
379
- @see -HTTPRequestOperationWithRequest:success:failure:
380
- */
381
- - (void)putPath:(NSString *)path
382
- parameters:(NSDictionary *)parameters
383
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
384
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
385
-
386
- /**
387
- Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
388
-
389
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
390
- @param parameters The parameters to be encoded and appended as the query string for the request URL.
391
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
392
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
393
-
394
- @see -HTTPRequestOperationWithRequest:success:failure:
395
- */
396
- - (void)deletePath:(NSString *)path
397
- parameters:(NSDictionary *)parameters
398
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
399
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
400
-
401
- /**
402
- Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue.
403
-
404
- @param path The path to be appended to the HTTP client's base URL and used as the request URL.
405
- @param parameters The parameters to be encoded and set in the request HTTP body.
406
- @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
407
- @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
408
-
409
- @see -HTTPRequestOperationWithRequest:success:failure:
410
- */
411
- - (void)patchPath:(NSString *)path
412
- parameters:(NSDictionary *)parameters
413
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
414
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
415
- @end
416
-
417
- ///----------------
418
- /// @name Constants
419
- ///----------------
420
-
421
- /**
422
- ### Network Reachability
423
-
424
- The following constants are provided by `AFHTTPClient` as possible network reachability statuses.
425
-
426
- enum {
427
- AFNetworkReachabilityStatusUnknown,
428
- AFNetworkReachabilityStatusNotReachable,
429
- AFNetworkReachabilityStatusReachableViaWWAN,
430
- AFNetworkReachabilityStatusReachableViaWiFi,
431
- }
432
-
433
- `AFNetworkReachabilityStatusUnknown`
434
- The `baseURL` host reachability is not known.
435
-
436
- `AFNetworkReachabilityStatusNotReachable`
437
- The `baseURL` host cannot be reached.
438
-
439
- `AFNetworkReachabilityStatusReachableViaWWAN`
440
- The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
441
-
442
- `AFNetworkReachabilityStatusReachableViaWiFi`
443
- The `baseURL` host can be reached via a Wi-Fi connection.
444
-
445
- ### Keys for Notification UserInfo Dictionary
446
-
447
- Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
448
-
449
- `AFNetworkingReachabilityNotificationStatusItem`
450
- A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
451
- The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
452
-
453
- ### Parameter Encoding
454
-
455
- The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
456
-
457
- enum {
458
- AFFormURLParameterEncoding,
459
- AFJSONParameterEncoding,
460
- AFPropertyListParameterEncoding,
461
- }
462
-
463
- `AFFormURLParameterEncoding`
464
- Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise.
465
-
466
- `AFJSONParameterEncoding`
467
- Parameters are encoded into JSON in the message body.
468
-
469
- `AFPropertyListParameterEncoding`
470
- Parameters are encoded into a property list in the message body.
471
- */
472
-
473
- ///----------------
474
- /// @name Functions
475
- ///----------------
476
-
477
- /**
478
- Returns a query string constructed by a set of parameters, using the specified encoding.
479
-
480
- @param parameters The parameters used to construct the query string
481
- @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs.
482
-
483
- @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&".
484
-
485
- If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component.
486
-
487
- @return A percent-escaped query string
488
- */
489
- extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
490
-
491
- ///--------------------
492
- /// @name Notifications
493
- ///--------------------
494
-
495
- /**
496
- Posted when network reachability changes.
497
- This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
498
-
499
- @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
500
- */
501
- #ifdef _SYSTEMCONFIGURATION_H
502
- extern NSString * const AFNetworkingReachabilityDidChangeNotification;
503
- extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
504
- #endif
505
-
506
- #pragma mark -
507
-
508
- extern NSUInteger const kAFUploadStream3GSuggestedPacketSize;
509
- extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
510
-
511
- /**
512
- The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
513
- */
514
- @protocol AFMultipartFormData
515
-
516
- /**
517
- Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
518
-
519
- @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
520
- @param name The name to be associated with the specified data. This parameter must not be `nil`.
521
- @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
522
-
523
- @return `YES` if the file data was successfully appended, otherwise `NO`.
524
-
525
- @discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively.
526
- */
527
- - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
528
- name:(NSString *)name
529
- error:(NSError * __autoreleasing *)error;
530
-
531
- /**
532
- Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
533
-
534
- @param data The data to be encoded and appended to the form data.
535
- @param name The name to be associated with the specified data. This parameter must not be `nil`.
536
- @param filename The filename to be associated with the specified data. This parameter must not be `nil`.
537
- @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
538
- */
539
- - (void)appendPartWithFileData:(NSData *)data
540
- name:(NSString *)name
541
- fileName:(NSString *)fileName
542
- mimeType:(NSString *)mimeType;
543
-
544
- /**
545
- Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
546
-
547
- @param data The data to be encoded and appended to the form data.
548
- @param name The name to be associated with the specified data. This parameter must not be `nil`.
549
- */
550
-
551
- - (void)appendPartWithFormData:(NSData *)data
552
- name:(NSString *)name;
553
-
554
- /**
555
- Appends HTTP headers, followed by the encoded data and the multipart form boundary.
556
-
557
- @param headers The HTTP headers to be appended to the form data.
558
- @param body The data to be encoded and appended to the form data.
559
- */
560
- - (void)appendPartWithHeaders:(NSDictionary *)headers
561
- body:(NSData *)body;
562
-
563
- /**
564
- Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
565
-
566
- @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
567
- @param delay Duration of delay each time a packet is read. By default, no delay is set.
568
-
569
- @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
570
- */
571
- - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
572
- delay:(NSTimeInterval)delay;
573
-
574
- @end