mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 14:50:17 +00:00
cache control /cc @mattrobenolt
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user