NSURLConnection delegado no recibe su método didReceiveAuthenticationChallenge sobre el estado del servidor 401

StackOverflow https://stackoverflow.com/questions/727600

Pregunta

he configurar un NSURLConnection sencilla para consultar un servidor http.

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

El servidor responde con el código 401 y establecer la cabecera WWW-Authenticate

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:

Me imagino que esto sería enviar un mensaje a la conexión de mi delegado: didReceiveAuthenticationChallenge: método, pero no lo hace

.

También he implementado

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

Sólo para asegurarse de que no trata de enviar a lo largo credenciales almacenadas en caché de mi llavero, que no lo hace.

¿Fue útil?

Solución

La cabecera WWW-Authenticate se ve mal formado, trate de:

WWW-Authenticate: Basic realm="My Realm"
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top