0

NSURLRequest + NSHTTPURLResponse is clearly the way to role. How do I just grab the header info?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
dugla
  • 12,774
  • 26
  • 88
  • 136

2 Answers2

3

Calling allHeaderFields on your NSHTTPURLResponse will return them as a dictionary.

[response allHeaderFields] 

where response is your NSHTTPURLResponse object.

paulthenerd
  • 9,487
  • 2
  • 35
  • 29
  • 4
    Additionally, using an NSMutableURLRequest and calling [request setHTTPMethod:@"HEAD"] will result in less bandwidth being used (if the server supports it) – rpetrich Aug 30 '09 at 11:35
  • 1
    rpetrich, This is the critical bit I was looking for. I DON'T want to grab the entire message body of the URL which is many gigabytes. Thanks so much for the pointer. Cheers, Doug – dugla Aug 30 '09 at 12:23
-2

⌘-doubleclick on a reference to "NSHTTPURLResponse" in your code, and it will show you the documentation.

Nathan de Vries
  • 15,481
  • 4
  • 49
  • 55