[New-bugs-announce] [issue22496] urllib2 fails against IIS (urllib2 can't parse 401 reply www-authenticate headers)

Mathieu Dupuy report at bugs.python.org
Thu Sep 25 17:48:51 CEST 2014


New submission from Mathieu Dupuy:

When connecting to a IIS server, it replies that:

Unauthorized Server: Microsoft-IIS/7.5
WWW-Authenticate: Digest qop="auth",algorithm=MD5-sess,nonce="+Upgraded+v1fe2ba746797cfd974e85f9f6dbdd6e514ec45becd2d8cf0112c764c676ad4a00f98517bb166e467dcad4b942254bd9b71d447e3529c509d2",charset=utf-8,realm="Digest"
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Thu, 25 Sep 2014 15:11:03 GMT
Connection: close
Content-Length: 0

which blew python 2.7 utllib2 like this:

File "tut2.py", line 23, in <module>
    response = opener.open('https://exca010.encara.local.ads/ews/Services.wsdl')
  File "/usr/lib64/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib64/python2.7/urllib2.py", line 524, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.7/urllib2.py", line 442, in error
    result = self._call_chain(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 1090, in http_error_401
    host, req, headers)
  File "/usr/lib64/python2.7/urllib2.py", line 973, in http_error_auth_reqed
    return self.retry_http_digest_auth(req, authreq)
  File "/usr/lib64/python2.7/urllib2.py", line 977, in retry_http_digest_auth
    chal = parse_keqv_list(parse_http_list(challenge))
  File "/usr/lib64/python2.7/urllib2.py", line 1259, in parse_keqv_list
    k, v = elt.split('=', 1)
ValueError: need more than 1 value to unpack


urllib2 seems to assume that every www-authenticate header value will be a list of equal-signe-separated tuple.

On python3, the error is different and trigger this http://bugs.python.org/issue2202 (which is soon-to-be-fixed)

----------
components: Library (Lib)
messages: 227543
nosy: deronnax
priority: normal
severity: normal
status: open
title: urllib2 fails against IIS (urllib2 can't parse 401 reply www-authenticate headers)
type: crash
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22496>
_______________________________________


More information about the New-bugs-announce mailing list