Take the 2-minute tour ×

How can I read the data from the header sent by in the server response. I am using NSURLConnection to send the request.

share|improve this question

1 Answer 1

up vote 36 down vote accepted

If the URL is an HTTP URL, then the NSURLResponse that you receive in your connection's delegate's -connection:didReceiveResponse: method (or via another method) will be an NSHTTPURLResponse, which has an -allHeaderFields method that lets you access the headers.

NSURLResponse* response = // the response, from somewhere
NSDictionary* headers = [(NSHTTPURLResponse *)response allHeaderFields];
// now query `headers` for the header you want
share|improve this answer

Your Answer


