views:

321

answers:

1

Hi all,

I need to deal with an http authentication (401) using the NSURLConnection class, so I implemented the "connection:didReceiveAuthenticationChallenge:" delegate method.

In this method, to respond to the server challenge, I need an information contained in the http server response headers (the WWW-Authenticate header one). My problem is how can I access this headers from this method ?

(I saw that the response headers are available from the NSURLResponse object (allHeaderFields method), but this object is passed to "connection:didReceiveResponse:" delegate method, too late to respond to the server challenge. )

Regards. Sébastien.

+2  A: 

NSURLAuthenticationChallenge has a -failureResponse method. If that object is an NSHTTPURLResponse (and it should be for HTTP connections!), you can query it for -allHeaderFields.

Mike Abdullah
Right Mike, it works fine. Thanks a lot.Regards.Sébastien.
Sébastien