gesomax / httplib2

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

"ValueError" when ".cache" enabled and fetching certain url #58

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. h = httplib2.Http(".cache")
2. resp, content =
h.request('http://www.globalgateway.org/pdf/home%20corners.pdf')

What is the expected output? What do you see instead?

Expect to see nothing instead see:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/httplib2/__init__.py", line 1050,
in request
    (response, content) = self._request(conn, authority, uri, request_uri,
method, body, headers, redirections, cachekey)
  File "/usr/lib/python2.5/site-packages/httplib2/__init__.py", line 907,
in _request
    _updateCache(headers, response, content, self.cache, cachekey)
  File "/usr/lib/python2.5/site-packages/httplib2/__init__.py", line 339,
in _updateCache
    cc_response = _parse_cache_control(response_headers)
  File "/usr/lib/python2.5/site-packages/httplib2/__init__.py", line 202,
in _parse_cache_control
    retval = dict(parts_with_args + parts_wo_args)
ValueError: dictionary update sequence element #0 has length 3; 2 is required

What version of the product are you using? On what operating system?
httplib2-0.4.0 on 64 bit Intrepid Ubuntu using python 2.5

Please provide any additional information below.
Doing "h = httplib2.Http()" stops the issue occurring. 

Original issue reported on code.google.com by bassdr...@gmail.com on 8 Jul 2009 at 1:22

GoogleCodeExporter commented 8 years ago
Recorded here for posterity, the Cache-Control: header returned by this server 
is
what is causing the problem:

$ curl --head "http://www.globalgateway.org/pdf/home%20corners.pdf"
HTTP/1.1 200 OK
Cache-Control: Max-age=3600;post-check=1800,pre-check=3600
Content-Length: 820983
Content-Type: application/pdf
Last-Modified: Wed, 23 Aug 2006 13:13:14 GMT
Accept-Ranges: bytes
ETag: "82932fe4b5c6c61:4d38"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Thu, 16 Jul 2009 23:10:59 GMT

Original comment by joe.gregorio@gmail.com on 16 Jul 2009 at 11:28

GoogleCodeExporter commented 8 years ago
Fixed in trunk.

Problem was that malformed cache-control headers could cause an exception.

Original comment by joe.gregorio@gmail.com on 17 Jul 2009 at 12:12