Wednesday, January 5, 2011

How to Debug NSURLConnection HTTP Headers

When you are connected to a server somewhere in internet and something doesn't seem to be quite right, what would you do?

That's right, check HTTP headers from server response:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    NSHTTPURLResponse *httpResponse =
       (NSHTTPURLResponse *)response;
    NSLog(@"%@", [httpResponse allHeaderFields]);
}
Why am I writing this blog? So that I wouldn't have to figure out same things over and over again! Now I've researched fourth time in two projects how to debug all HTTP headers in didReceiveResponse, so it was time to write it down.

Repeating things makes you faster, but next time I'll just google it - or check tag cloud from this blog :)

No comments:

Post a Comment