From b5bbef09c5649e403e045d049c2df7592fca0dba Mon Sep 17 00:00:00 2001 From: Suby Raman Date: Sat, 14 Jan 2017 00:47:28 -0500 Subject: [PATCH] add redirect method --- sanic/response.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sanic/response.py b/sanic/response.py index f6422d5f..9c7bd2b5 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -172,7 +172,7 @@ async def file(location, mime_type=None, headers=None): def redirect(to, headers=None, status=302, - content_type=None): + content_type="text/html; charset=utf-8"): """ Aborts execution and causes a 302 redirect (by default). @@ -180,12 +180,9 @@ def redirect(to, headers=None, status=302, :param headers: optional dict of headers to include in the new request :param status: status code (int) of the new request, defaults to 302 :param content_type: - the content type (string) of the response, defaults to None + the content type (string) of the response :returns: the redirecting Response """ - if not content_type: - content_type = "text/html; charset=utf-8" - headers = headers or {} # According to RFC 7231, a relative URI is now permitted.