Comment 5 for bug 274815

Revision history for this message
Leonard Richardson (leonardr) wrote : Re: Cached binary files aren't retrieved from cache

The fix is really simple.

=== modified file 'src/lazr/restfulclient/_browser.py'
--- src/lazr/restfulclient/_browser.py 2009-03-26 20:50:28 +0000
+++ src/lazr/restfulclient/_browser.py 2009-04-27 15:38:01 +0000
@@ -200,7 +200,9 @@
         response, content = self._connection.request(
             str(url), method=method, body=data, headers=headers)
         # Turn non-2xx responses into exceptions.
- if response.status // 100 != 2:
+ # 304 ("Not Modified") is okay because it means data was
+ # retrieved from the cache.
+ if response.status // 100 != 2 and response.status != 304:
             raise HTTPError(response, content)
         return response, content

Writing a test for this is not simple at all, because it relies on librarian-specific behavior. I may have to make the fake librarian more like the real librarian.