Backport various bug fixes from trunk. The 2.1 maintenance branch is now identical to the trunk through rev 1.54 of httplib.py.