Created
September 11, 2010 07:51
-
-
Save wjessop/574965 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (Response *)get:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password { | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithUrl:[NSURL URLWithString:url] andMethod:@"GET"]; | |
return [self sendRequest:request withUser:user andPassword:password]; | |
} | |
// to: | |
+ (Response *)get:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password { | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithUrl:[NSURL URLWithString:url] andMethod:@"GET"]; | |
for (NSDictionary *header in requestHeaders) | |
[request addValue:[header objectForKey:@"value"] forHTTPHeaderField:[header objectForKey:@"name"]]; | |
return [self sendRequest:request withUser:user andPassword:password]; | |
} |
At the expense of overwriting existing headers, such as any previously set "Accepts" header, but this may be OK for what you are doing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-[NSURLRequest setAllHTTPHeaderFields:]
saves you the for loop.