Handle If-None-Match

This commit is contained in:
Matt Robenolt
2013-05-19 11:21:05 -07:00
parent e76957ff41
commit 27e3e7f426
3 changed files with 5 additions and 4 deletions
+1
View File
@@ -18,3 +18,4 @@ Patches and Suggestions
- Radomir Stevanovic (http://github.com/randomir)
- Steven Honson
- Cory Benfield (Lukasa) <cory@lukasa.co.uk>
- Matt Robenolt (https://github.com/mattrobenolt)
+1 -1
View File
@@ -30,7 +30,7 @@ Freely hosted in [HTTP](http://httpbin.org) &
- [`/html`](http://httpbin.org/html) Renders an HTML Page.
- [`/robots.txt`](http://httpbin.org/robots.txt) Returns some robots.txt rules.
- [`/deny`](http://httpbin.org/deny) Denied by robots.txt file.
- [`/cache`](http://httpbin.org/cache) Returns 200 unless an If-Modified-Since header is provided, when it returns a 304.
- [`/cache`](http://httpbin.org/cache) Returns 200 unless an If-Modified-Since or If-None-Match header is provided, when it returns a 304.
## DESCRIPTION
+3 -3
View File
@@ -332,10 +332,10 @@ def decode_base64(value):
@app.route('/cache', methods=('GET',))
def cache():
"""Returns a 304 if an If-Modified-Since header is present. Returns the same as a GET otherwise."""
if_modified = request.headers.get('If-Modified-Since')
"""Returns a 304 if an If-Modified-Since header or If-None-Match is present. Returns the same as a GET otherwise."""
is_conditional = request.headers.get('If-Modified-Since') or request.headers.get('If-None-Match')
if if_modified is None:
if is_conditional is None:
return view_get()
else:
return status_code(304)