Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: facebookarchive/three20
...
head fork: sco/three20
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 9 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
View
10 src/TTURLRequest.m
@@ -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];
@@ -67,6 +67,7 @@ - (void)dealloc {
[_timestamp release];
[_cacheKey release];
[_userInfo release];
+ [_headers release];
[super dealloc];
}
@@ -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];
View
8 src/TTURLRequestQueue.m
@@ -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];
View
13 src/Three20/TTURLRequest.h
@@ -7,6 +7,7 @@
NSString* _httpMethod;
NSData* _httpBody;
NSMutableDictionary* _parameters;
+ NSMutableDictionary* _headers;
NSString* _contentType;
NSMutableArray* _delegates;
id<TTURLResponse> _response;
@@ -21,6 +22,11 @@
}
/**
+ * custom request headers
+ */
+@property(nonatomic,readonly) NSMutableDictionary* headers;
+
+/**
* An object that receives messages about the progress of the request.
*/
@property(nonatomic,readonly) NSMutableArray* delegates;
@@ -43,7 +49,7 @@
/**
* The HTTP body to send with the request.
*/
-@property(nonatomic,readonly) NSData* httpBody;
+@property(nonatomic,copy) NSData* httpBody;
/**
* The content type of the data in the request.
@@ -101,6 +107,11 @@
*/
- (void)cancel;
+/**
+ * Sets the specified HTTP header field.
+ */
+- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
+
@end
///////////////////////////////////////////////////////////////////////////////////////////////////

No commit comments for this range

Something went wrong with that request. Please try again.