views:

945

answers:

1

I've setup a simple NSURLConnection to query an http-server.

GET /path HTTP/1.1
Host: 192.168.1.161:8282
User-Agent: NetTest1.0 CFNetwork/441.0.2 Darwin/9.6.0
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Pragma: no-cache
Connection: keep-alive

The server responds with code 401 and the WWW-Authenticate header set

HTTP/1.1 401
Connection: close
Pragma: no-cache
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Cache-control: no-cache
Cache-last-checked: Thu, 01 Dec 1994 16:00:00 GMT
Last-modified: Tue, 07 Apr 02009 22:55:48 CEST
Content-type: text/html; charset=iso-8859-1
WWW-Authenticate: Basic realm:

I would imagine this would send a message to my delegate's connection: didReceiveAuthenticationChallenge: method, but it does not.

I've also implemented

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection {
  return FALSE;
}

Just to make sure it doesn't try to send along cached credentials from my keychain, which it does not.

+3  A: 

The WWW-Authenticate header looks malformed, try:

WWW-Authenticate: Basic realm="My Realm"
dbarker