Created
July 21, 2012 12:19
-
-
Save gronnbeck/3155694 to your computer and use it in GitHub Desktop.
Build a request with custom cookie header... Trying to..
This file contains 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
NSURL *url = [NSURL URLWithString:@"ws://localhost:8080/api/v0/_sync"]; | |
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; | |
NSString *u = @"ewogICAgImlzX2FkbWluIjogZmFsc2UsIAogICAgInVzZXJfaWQiOiAzMTAwNTIwMTg3LCAKICAgICJlbWFpbCI6ICJub25fYWRtaW5AaG9vcGxhLm5vIiwgCiAgICAiZGF0YSI6IG51bGwsIAogICAgIm9yZ2FuaXphdGlvbnMiOiBbCiAgICAgICAgWwogICAgICAgICAgICAxOTE0NzgzNjkzLCAKICAgICAgICAgICAgIm9yZ2FuaXphdGlvbjE3NSIsIAogICAgICAgICAgICB0cnVlCiAgICAgICAgXQogICAgXQp9"; | |
NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary]; | |
[cookieProperties setObject:@"u" forKey:NSHTTPCookieName]; | |
[cookieProperties setObject:u forKey:NSHTTPCookieValue]; | |
[cookieProperties setObject:@"localhost" forKey:NSHTTPCookieDomain]; | |
[cookieProperties setObject:@"localhost" forKey:NSHTTPCookieOriginURL]; | |
[cookieProperties setObject:@"/" forKey:NSHTTPCookiePath]; | |
[cookieProperties setObject:@"0" forKey:NSHTTPCookieVersion]; | |
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties]; | |
NSArray *cookies = [NSArray arrayWithObject:cookie]; | |
NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies]; | |
NSLog(@"Headers: %@", headers); | |
[request setAllHTTPHeaderFields:headers]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment