BigMacchia / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

httplib2 sends "authorization" header in all lowercase #169

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
So, after quite a bit of time trying to test authentication problems, I 
discovered that when httplib2 answers a 401 challenge, it sends the 
authorization header as "authorization: ______".

In the HTTP spec, this is a-ok to do.

However, several servers, specifically IIS, don't consume it properly, because 
they want "Authorization", with a capital "A".

While I understand that the servers should take both, it would be nice if 
httplib2 just sent it with a capital "A".

Original issue reported on code.google.com by lukesnee...@gmail.com on 25 Aug 2011 at 7:48

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
version: 0.7.0
file: httplib2.__init__.py

line 1488~1490

    if isinstance(info, httplib.HTTPResponse):
        for key, value in info.getheaders():
            self[key.lower()] = value

Why you do lower() for all header fields?

I think you should remove lower(), though RFC 2616 say 'Field names are 
case-insensitive'.

http://tools.ietf.org/html/rfc2616#section-4.2

Original comment by shuge....@gmail.com on 7 Oct 2011 at 11:27

GoogleCodeExporter commented 8 years ago
The following should normalize header keys to Xxxx or Xxxx-Xxxx

__init__.py line 252:

NORMALIZE_SPACE = re.compile(r'(?:\r\n)?[ \t]+')
def _normalize_headers(headers):
    normalize_key = lambda k: '-'.join([l.capitalize() for l in k.split('-')])
    return dict([ (normalize_key(key), NORMALIZE_SPACE.sub(value, ' ').strip())  for (key, value) in headers.iteritems()])

Original comment by r...@perkville.com on 12 Jan 2012 at 5:45

GoogleCodeExporter commented 8 years ago
I also seems have issues: "-" are converting to "_". If it's a known issue with 
a patch pleas?

Original comment by gkhachik...@gmail.com on 2 Dec 2012 at 1:06