From 2d505e0bb5d68f67b8df6607e1c8663722656536 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 12 Jun 2011 23:15:48 -0400 Subject: [PATCH] redirect --- httpbin/helpers.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index d5ca84d..a85cc53 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -49,13 +49,15 @@ def get_headers(): def status_code(code): """Returns response object of given status code.""" + redirect = dict(headers=dict(location=REDIRECT_LOCATION)) + code_map = { - 301: dict(headers=dict(location=REDIRECT_LOCATION)), - 302: dict(headers=dict(location=REDIRECT_LOCATION)), - 303: dict(headers=dict(location=REDIRECT_LOCATION)), + 301: redirect, + 302: redirect, + 303: redirect, 304: dict(data=''), - 305: dict(headers=dict(location=REDIRECT_LOCATION)), - 307: dict(headers=dict(location=REDIRECT_LOCATION)), + 305: redirect, + 307: redirect, 401: dict(headers={'WWW-Authenticate': 'Basic realm="Fake Realm"'}), 407: dict(headers={'Proxy-Authenticate': 'Basic realm="Fake Realm"'}), 418: dict(