Permalink
Browse files

[Dox] Document and clean up the PUT logic.

  • Loading branch information...
1 parent 739cd38 commit c05a31d9e906645266361fbc4fbbfb8f96f582d3 @jverkoey jverkoey committed Feb 18, 2010
Showing with 18 additions and 10 deletions.
  1. +6 −3 src/TTURLRequest.m
  2. +5 −2 src/TTURLRequestQueue.m
  3. +7 −5 src/Three20/TTURLRequest.h
View
@@ -144,7 +144,8 @@ - (NSString *)md5HexDigest:(NSString*)input {
//////////////////////////////////////////////////////////////////////////////////////////////////
- (NSString*)generateCacheKey {
- if ([_httpMethod isEqualToString:@"POST"] || [_httpMethod isEqualToString:@"PUT"]) {
+ if ([_httpMethod isEqualToString:@"POST"]
+ || [_httpMethod isEqualToString:@"PUT"]) {
NSMutableString* joined = [[[NSMutableString alloc] initWithString:self.URL] autorelease];
NSEnumerator* e = [_parameters keyEnumerator];
for (id key; key = [e nextObject]; ) {
@@ -249,7 +250,8 @@ - (NSMutableDictionary*)parameters {
- (NSData*)httpBody {
if (_httpBody) {
return _httpBody;
- } else if ([[_httpMethod uppercaseString] isEqualToString:@"POST"] || [[_httpMethod uppercaseString] isEqualToString:@"PUT"]) {
+ } else if ([[_httpMethod uppercaseString] isEqualToString:@"POST"]
+ || [[_httpMethod uppercaseString] isEqualToString:@"PUT"]) {
return [self generatePostBody];
} else {
return nil;
@@ -261,7 +263,8 @@ - (NSData*)httpBody {
- (NSString*)contentType {
if (_contentType) {
return _contentType;
- } else if ([_httpMethod isEqualToString:@"POST"] || [_httpMethod isEqualToString:@"PUT"]) {
+ } else if ([_httpMethod isEqualToString:@"POST"]
+ || [_httpMethod isEqualToString:@"PUT"]) {
return [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kStringBoundary];
} else {
return nil;
@@ -346,8 +346,11 @@ - (BOOL)sendRequest:(TTURLRequest*)request {
request.isLoading = YES;
TTRequestLoader* loader = nil;
- if (![request.httpMethod isEqualToString:@"POST"] && ![request.httpMethod isEqualToString:@"PUT"]) {
- // Next, see if there is an active loader for the URL and if so join that bandwagon
+
+ // If we're not POSTing or PUTting data, let's see if we can jump on an existing request.
+ if (![request.httpMethod isEqualToString:@"POST"]
+ && ![request.httpMethod isEqualToString:@"PUT"]) {
+ // Next, see if there is an active loader for the URL and if so join that bandwagon.
loader = [_loaders objectForKey:request.cacheKey];
if (loader) {
[loader addRequest:request];
@@ -69,6 +69,7 @@
*
* @example @"POST"
* @example @"GET"
+ * @example @"PUT"
* @default nil (equivalent to @"GET")
*/
@property(nonatomic,copy) NSString* httpMethod;
@@ -84,20 +85,21 @@
/**
* The HTTP body to send with the request.
*
- * If provided, will always be used. Please consider this when using POST methods: if httpBody is
- * provided, then the POST data generated from the parameters property will not be used.
+ * If provided, will always be used. Please consider this when using POST/PUT methods: if
+ * httpBody is provided, then the POST/PUT data generated from the parameters property will not
+ * be used.
*/
@property(nonatomic,retain) NSData* httpBody;
/**
* The content type of the data in the request.
*
- * If not provided and httpMethod is POST, then contentType is multipart/form-data.
+ * If not provided and httpMethod is POST/PUT, then contentType is multipart/form-data.
*/
@property(nonatomic,copy) NSString* contentType;
/**
- * Parameters to use for an HTTP post.
+ * Parameters to use for an HTTP POST/PUT.
*/
@property(nonatomic,readonly) NSMutableDictionary* parameters;
@@ -120,7 +122,7 @@
/**
* If no cache key is provided, a unique key is generated from the request data. If the request
- * is a POST request, then the POST parameters are also used to generate the cache key.
+ * is a POST/PUT request, then the POST/PUT parameters are also used to generate the cache key.
*
* By setting the cacheKey, you may override the default cache key generator with your own.
*/

0 comments on commit c05a31d

Please sign in to comment.