Merge remote-tracking branch 'origin/master'

This commit is contained in:
Kenneth Reitz
2013-05-19 13:00:19 -04:00
4 changed files with 14 additions and 0 deletions
+1
View File
@@ -17,3 +17,4 @@ Patches and Suggestions
- Flavio Percoco
- Radomir Stevanovic (http://github.com/randomir)
- Steven Honson
- Cory Benfield (Lukasa) <cory@lukasa.co.uk>
+1
View File
@@ -30,6 +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.
## DESCRIPTION
+11
View File
@@ -330,5 +330,16 @@ def decode_base64(value):
return base64.urlsafe_b64decode(encoded).decode('utf-8')
@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')
if if_modified is None:
return view_get()
else:
return status_code(304)
if __name__ == '__main__':
app.run()
+1
View File
@@ -31,6 +31,7 @@
<li><a href="/html" data-bare-link="true"><code>/html</code></a> Renders an HTML Page.</li>
<li><a href="/robots.txt" data-bare-link="true"><code>/robots.txt</code></a> Returns some robots.txt rules.</li>
<li><a href="/deny" data-bare-link="true"><code>/deny</code></a> Denied by robots.txt file.</li>
<li><a href="/cache" data-bare-link="true"><code>/cache</code></a> Returns 200 unless an If-Modified-Since header is provided, when it returns a 304 Not Modified.</li>
</ul>