[MERGE] Fix bug #229076 by fixing header names before sending the request.
John Arbash Meinel
john at arbash-meinel.com
Sat May 17 19:04:51 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Vincent Ladeuil wrote:
| Hi,
|
| Never leave a FIXME without giving detailed explanations... or
| you'll end up doing all the research work again :)
|
| See patch for explanations, roughly,
| python2.4/2.5/httplib/urllib/urllib2 internally capitalized
| (User-agent) header names (or lowercase (user-agent) them, it
| depends) when in fact at least one server/proxy on the earth
| expect them to be titled (User-Agent) and abort connections
| otherwise. Unfortunately, it is used by www.gnome.org* ;)
|
| It turns out python2.5 urllib2 in some recent version (didn't
| search which one exactly) fixed it by using title.
|
| Unfortunately it did it in a function I had to override to handle
| persistent connections (among other things).
|
| Anyway, thanks for reading until here, I'm just being a bit
| verbose to respect my introduction ;-)
|
| Vincent
|
| *: The bug is fixed, but I'm curious as a cat, so I'd like to
| know what is being used there, any pointers greatly appreciated.
|
|
=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
- --- bzrlib/transport/http/_urllib2_wrappers.py 2008-04-24 07:22:53 +0000
+++ bzrlib/transport/http/_urllib2_wrappers.py 2008-05-17 17:53:47 +0000
@@ -30,6 +30,10 @@
~ And a custom Request class that lets us track redirections, and
~ handle authentication schemes.
+
+For coherency with python libraries, we use capitalized header names throughout
+the code, even if the header names will be titled just before sending the
+request (see AbstractHTTPHandler.do_open).
~ """
~ DEBUG = 0
@@ -407,10 +411,6 @@
~ _default_headers = {'Pragma': 'no-cache',
~ 'Cache-control': 'max-age=0',
~ 'Connection': 'Keep-Alive',
- - # FIXME: Spell it User-*A*gent once we
- - # know how to properly avoid bogus
- - # urllib2 using capitalize() for headers
- - # instead of title(sp?).
~ 'User-agent': 'bzr/%s (urllib)' % bzrlib_version,
~ 'Accept': '*/*',
~ }
^- You added the comment, but I see "Cache-control" rather than "Cache-Control"
and still have "User-Agent".
Otherwise
BB:approve
I'm also curious why gnome is being that strict, I don't remember the spec being
that strict.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkgvHkMACgkQJdeBCYSNAAO9PgCglUpnQUTslIpel4ZkgQ7zDcPH
2hkAoInGx3DIwBuSZpv7ShfYnhQp5VQq
=cqdC
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list