summaryrefslogtreecommitdiff
path: root/python3/httplib2
diff options
context:
space:
mode:
authorJoe Gregorio <joe@bitworking.org>2009-07-16 14:57:52 -0400
committerJoe Gregorio <joe@bitworking.org>2009-07-16 14:57:52 -0400
commite202d210b618cba29d2c300b17a2ffb8e003fd14 (patch)
treeddcd15c9bcb7429d82f4f5dc07c2ecd2a4255f0f /python3/httplib2
parentb628c0b6acf4d5ce481391ace3d6c0410b2918fd (diff)
downloadhttplib2-e202d210b618cba29d2c300b17a2ffb8e003fd14.tar.gz
Fixed issue #12 - Cache-Control: only-if-cached incorrectly does request if item not in cache
Diffstat (limited to 'python3/httplib2')
-rwxr-xr-xpython3/httplib2/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index d660796..389c3fe 100755
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -1074,7 +1074,13 @@ a string that contains the response entity body.
self.cache.delete(cachekey)
content = new_content
else:
- (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
+ cc = _parse_cache_control(headers)
+ if 'only-if-cached'in cc:
+ info['status'] = '504'
+ response = Response(info)
+ content = b""
+ else:
+ (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
except Exception as e:
if self.force_exception_to_status_code:
if isinstance(e, HttpLib2ErrorWithResponse):