cache control /cc @mattrobenolt

This commit is contained in:
Kenneth Reitz
2013-07-10 18:00:54 -04:00
parent 9c8d26dd09
commit 802b1ea739
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -32,11 +32,11 @@ Freely hosted in [HTTP](http://httpbin.org) &
- [`/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 or If-None-Match header is provided, when it returns a 304.
- [`/cache/:n`](http://httpbin.org/cache/60) Sets a Cache-Control header for *n* seconds.
- [`/bytes/:n`](http://httpbin.org/bytes/1024) Generates *n* random bytes of binary data, accepts optional *seed* integer parameter.
- [`/stream-bytes/:n`](http://httpbin.org/stream-bytes/1024) Streams *n* random bytes of binary data, accepts optional *seed* and *chunk_size* integer parameters.
- [`/links/:n`](http://httpbin.org/links/10) Returns page containing *n* HTML links.
## DESCRIPTION
Testing an HTTP Library can become difficult sometimes. PostBin.org is fantastic
+8
View File
@@ -368,6 +368,14 @@ def cache():
return status_code(304)
@app.route('/cache/<int:value>')
def cache_control(value):
"""Sets a Cache-Control header."""
response = view_get()
response.headers['Cache-Control'] = 'public, max-age={0}'.format(value)
return response
@app.route('/bytes/<int:n>')
def random_bytes(n):
"""Returns n random bytes generated with given seed."""