From 5c71ef399004ef5555c39eb58a7093c134639e9f Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 8 Feb 2012 17:53:44 +1000 Subject: [PATCH 1/2] Add /delay/ endpoint for delayed responses. Fixes #26 --- httpbin/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/httpbin/core.py b/httpbin/core.py index 952b5aa..bb5d1b8 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -257,6 +257,15 @@ def digest_auth(qop=None, user='user', passwd='passwd'): return dict(authenticated=True, user=user) +@app.route('/delay/') +def delay_response(delay): + """Returns a delayed response""" + delay = min(delay, 30) + time.sleep(delay) + + return jsonify(get_dict( + 'url', 'args', 'form', 'data', 'origin', 'headers', 'files')) + @app.route('/base64/') def decode_base64(value): """Decodes base64url-encoded string""" From ed60c9612a10fc9883c4f7edf78721c58a2efa6e Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 8 Feb 2012 17:57:06 +1000 Subject: [PATCH 2/2] Note /delay/:n on index --- httpbin/templates/httpbin.1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/httpbin/templates/httpbin.1.html b/httpbin/templates/httpbin.1.html index 84b3a8e..2ce6678 100644 --- a/httpbin/templates/httpbin.1.html +++ b/httpbin/templates/httpbin.1.html @@ -24,6 +24,7 @@
  • /hidden-basic-auth/:user/:passwd 404'd BasicAuth.
  • /digest-auth/:qop/:user/:passwd Challenges HTTP Digest Auth.
  • /stream/:n Streams n lines.
  • +
  • /delay/:n Delays responding for n seconds.