What steps will reproduce the problem?
1. Set up a server that sends "Vary: X-Foo" with its representations.
(Whether the server sends X-Foo itself doesn't matter.)
2. Set up an httplib2.Http instance with a cache.
3. Make a GET request which does not include the X-Foo header.
4. Make the same GET request again.
What is the expected output? What do you see instead?
The two requests do not vary in their use of 'X-Foo' (as defined by RFC2616
section 13.6), since neither request uses that header at all. As such, the
second GET request should be served from the cache.
Actually, httplib2 decides that the requests do vary in their use of
'X-Foo', and sends the second GET request on to the web server.
What version of the product are you using? On what operating system?
httplib2 0.6.0 on Ubuntu Lucid.
Please provide any additional information below.
The problem is in this part of the request() method:
value = info[key]
if headers.get(header, '') != value:
cached_value = None
break
If the header mentioned in 'Vary' is never used in requests, info[key] will
be None and headers.get(header, '') will be the empty string. The
comparison will fail when it should succeed. Changing the headers.get()
default to None fixes this problem.
I've attached a patch that tests and fixes the problem.
Original issue reported on code.google.com by leonard....@gmail.com on 1 Apr 2010 at 7:27
Original issue reported on code.google.com by
leonard....@gmail.com
on 1 Apr 2010 at 7:27Attachments: