aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/lib/view_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/lib/view_utils.py')
-rw-r--r--pyaggr3g470r/lib/view_utils.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/pyaggr3g470r/lib/view_utils.py b/pyaggr3g470r/lib/view_utils.py
index fa5e1eec..0cfe62c4 100644
--- a/pyaggr3g470r/lib/view_utils.py
+++ b/pyaggr3g470r/lib/view_utils.py
@@ -7,14 +7,20 @@ def etag_match(func):
@wraps(func)
def wrapper(*args, **kwargs):
response = func(*args, **kwargs)
- if not type(response) is str:
+ if isinstance(response, Response):
+ etag = to_hash(response.data)
+ headers = response.headers
+ elif type(response) is str:
+ etag = to_hash(response)
+ headers = {}
+ else:
return response
- etag = to_hash(response)
if request.headers.get('if-none-match') == etag:
- response = Response(status=304, headers={'etag': etag,
- 'Cache-Control': 'pragma: no-cache'})
- else:
+ response = Response(status=304)
+ response.headers['Cache-Control'] \
+ = headers.get('Cache-Control', 'pragma: no-cache')
+ elif not isinstance(response, Response):
response = make_response(response)
- response.headers['etag'] = etag
+ response.headers['etag'] = etag
return response
return wrapper
bgstack15