trungn1992 / httplib2

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

URLs containing '*' (asterisk) characters causes an exception when the cache tries to create a file with an asterisk in the name #209

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

h = httplib2.Http('.cache')
h.add_credentials('my_name', 'secret', 'example.com')
url = 'http://example.com/path/something.json?param=*'
response, content = h.request(url, 'GET')

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

I expect to get a response from the server instead I see a stack trace 
complaining that the cache tried to create a file with an asterisk (from the 
url) in the file name. Removing the cache parameter from the httplib2.Http() 
call allows the results to return. The stack trace is at the bottom.

What version of the product are you using? On what operating system?

Python 3.2, httplib2 0.7.4 (according to a line in __init__.py).
Please provide any additional information below.

-------

  File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 1177, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 989, in _request
    _updateCache(headers, response, content, self.cache, cachekey)
  File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 394, in _updateCache
    cache.set(cachekey, text)
  File "C:\Python32\lib\site-packages\httplib2\__init__.py", line 684, in set
    f = open(cacheFullPath, "wb")
IOError: [Errno 22] Invalid argument: 
'.cache\\example.com,path,something.json,param=*,df489a56ec1ba765ccaae2e3f692199
3'

Original issue reported on code.google.com by c...@c-riddell.com on 17 May 2012 at 8:06

GoogleCodeExporter commented 8 years ago
Pass in the following for cache to the Http constructor:

  cache=FileCache('directory_name', safe=lambda x: md5.new(x).hexdigest())

Original comment by joe.gregorio@gmail.com on 28 Aug 2012 at 3:40

GoogleCodeExporter commented 8 years ago
I'm confused here. Your suggestion is a good work around, but doesn't the 
failure of the default cache naming algorithm indicate a bug?

Original comment by c...@c-riddell.com on 28 Aug 2012 at 3:53