Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/houyr/three20 into houyr/ma…
Browse files Browse the repository at this point in the history
…ster
  • Loading branch information
sco committed Apr 17, 2009
2 parents e0e37fd + fe17419 commit 3569cc1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/TTURLRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation TTURLRequest
httpBody = _httpBody, parameters = _parameters, contentType = _contentType,
cachePolicy = _cachePolicy, cacheExpirationAge = _cacheExpirationAge, cacheKey = _cacheKey,
timestamp = _timestamp, userInfo = _userInfo, isLoading = _isLoading,
shouldHandleCookies = _shouldHandleCookies, respondedFromCache = _respondedFromCache;
shouldHandleCookies = _shouldHandleCookies, respondedFromCache = _respondedFromCache, headers = _headers;

+ (TTURLRequest*)request {
return [[[TTURLRequest alloc] init] autorelease];
Expand Down Expand Up @@ -67,6 +67,7 @@ - (void)dealloc {
[_timestamp release];
[_cacheKey release];
[_userInfo release];
[_headers release];
[super dealloc];
}

Expand Down Expand Up @@ -161,6 +162,13 @@ - (NSData*)generatePostBody {

//////////////////////////////////////////////////////////////////////////////////////////////////

- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field {
if (!_headers) {
_headers = [[NSMutableDictionary alloc] init];
}
[_headers setObject:value forKey:field];
}

- (NSMutableDictionary*)parameters {
if (!_parameters) {
_parameters = [[NSMutableDictionary alloc] init];
Expand Down
8 changes: 8 additions & 0 deletions src/TTURLRequestQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ - (void)connectToURL:(NSURL*)url {
if (body) {
[urlRequest setHTTPBody:body];
}

NSMutableDictionary *headers = request.headers;
if (headers && [headers count] > 0){
for (NSString *key in headers) {
[urlRequest setValue:[headers objectForKey:key] forHTTPHeaderField:key];
}
}

}

_connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
Expand Down
11 changes: 11 additions & 0 deletions src/Three20/TTURLRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
NSString* _httpMethod;
NSData* _httpBody;
NSMutableDictionary* _parameters;
NSMutableDictionary* _headers;
NSString* _contentType;
NSMutableArray* _delegates;
id<TTURLResponse> _response;
Expand All @@ -20,6 +21,11 @@
BOOL _respondedFromCache;
}

/**
* custom request headers
*/
@property(nonatomic,readonly) NSMutableDictionary* headers;

/**
* An object that receives messages about the progress of the request.
*/
Expand Down Expand Up @@ -101,6 +107,11 @@
*/
- (void)cancel;

/**
* Sets the specified HTTP header field.
*/
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;

@end

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 3569cc1

Please sign in to comment.