pwsm / httplib2

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

URL username/password not properly handled #183

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It seems like httplib2 0.7.1 does not handle URL username/password properly.

>>> response, content = h.request('http://root@buffer.antifork.org/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/httplib2/__init__.py", line 1436, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/lib64/python2.6/site-packages/httplib2/__init__.py", line 1188, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/usr/lib64/python2.6/site-packages/httplib2/__init__.py", line 1129, in _conn_request
    raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at 
root@buffer.antifork.org

>>> response, content = h.request('http://root:password@buffer.antifork.org/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/httplib2/__init__.py", line 1320, in request
    proxy_info=self.proxy_info)
  File "/usr/lib64/python2.6/site-packages/httplib2/__init__.py", line 758, in __init__
    httplib.HTTPConnection.__init__(self, host, port, strict)
  File "/usr/lib64/python2.6/httplib.py", line 661, in __init__
    self._set_hostport(host, port)
  File "/usr/lib64/python2.6/httplib.py", line 686, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])

Using urllib I get these results

>>> import urllib
>>> fd = urllib.urlopen('http://root@buffer.antifork.org/')
>>> fd.headers.getheader('content-length')
'23170'
>>> fd.read()[:10]
'<html>\n  <'
>>>
>>> fd2 = urllib.urlopen('http://root:password@buffer.antifork.org/')
>>> fd2.headers.getheader('content-length')
'23170'
>>> fd2.read()[:10]
'<html>\n  <'

Original issue reported on code.google.com by angelo.d...@gmail.com on 4 Oct 2011 at 8:47