views:

191

answers:

2

Can't get "Location" header from response at all. Wireshark says that i've got one:

Location: http://*/index.html#0;sid=865a84f0212a3a35d8e9d5f68398e535

But

NSHTTPURLResponse *hr = (NSHTTPURLResponse*)response;
NSDictionary *dict = [hr allHeaderFields];          
NSLog(@"HEADERS : %@",[dict description]);

Produces this:

HEADERS : {
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "text/html";
    Date = "Thu, 25 Mar 2010 08:12:08 GMT";
    "Last-Modified" = "Sat, 29 Nov 2008 15:50:54 GMT";
    Server = "nginx/0.7.59";
    "Transfer-Encoding" = Identity;
}

No location anywhere. How to get it? I need this "sid" thing.

+1  A: 

NSHTTPURLResponse is a subclass of NSURLResponse so you can just ask it for its URL. This returns an NSURL object from which you can get the URL components such as the query, parameter string or fragment. In your case you want the fragment component:

NSURL* url = [response URL];
NSString* fragment = [url fragment];
//fragment should be: 0;sid=865a84f0212a3a35d8e9d5f68398e535
Rob Keniger
Thank u very much! It helped! =)
aspcartman
A: 

But now i need to get two of the Set-Cookie parameters. WireShark:

Set-Cookie: remixmid=69536; expires=Mon, 21-Mar-2011 18:16:00 GMT; path=/; domain=login.userapi.com Set-Cookie: remixpassword=2d01a37deddcf8488152e1645c84da99f02ef4ede6a359c6b31c5570; expires=Sun, 27-Mar-2011 17:01:25 GMT; path=/;

the [.... allHeaderFields] ignores all cookies =( Have no idea how to do this.

aspcartman