From f47e571d927b252e9f9383dbad3c33746321dd5a Mon Sep 17 00:00:00 2001 From: Tue Topholm Date: Thu, 1 Jun 2017 22:53:56 +0200 Subject: [PATCH 1/3] Added content_type to be set for son response --- sanic/response.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanic/response.py b/sanic/response.py index 9a304bb7..645bcaa2 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -233,7 +233,7 @@ class HTTPResponse(BaseHTTPResponse): return self._cookies -def json(body, status=200, headers=None, **kwargs): +def json(body, status=200, headers=None, content_type="application/json", **kwargs): """ Returns response object with body in json format. :param body: Response data to be serialized. @@ -242,7 +242,7 @@ def json(body, status=200, headers=None, **kwargs): :param kwargs: Remaining arguments that are passed to the json encoder. """ return HTTPResponse(json_dumps(body, **kwargs), headers=headers, - status=status, content_type="application/json") + status=status, content_type=content_type) def text(body, status=200, headers=None, From c102e761464e0989d2a39faf8898932c09e4d0c8 Mon Sep 17 00:00:00 2001 From: Tue Topholm Date: Thu, 1 Jun 2017 23:01:27 +0200 Subject: [PATCH 2/3] Fixed line width --- sanic/response.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sanic/response.py b/sanic/response.py index 645bcaa2..0f4d1356 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -233,7 +233,8 @@ class HTTPResponse(BaseHTTPResponse): return self._cookies -def json(body, status=200, headers=None, content_type="application/json", **kwargs): +def json(body, status=200, headers=None, + content_type="application/json", **kwargs): """ Returns response object with body in json format. :param body: Response data to be serialized. From 3d97fd8d2a17ae74aaceea07515a48436cbc7cf0 Mon Sep 17 00:00:00 2001 From: Tue Topholm Date: Thu, 1 Jun 2017 23:09:37 +0200 Subject: [PATCH 3/3] Removed whitespace --- sanic/response.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanic/response.py b/sanic/response.py index 0f4d1356..ea233d9a 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -233,7 +233,7 @@ class HTTPResponse(BaseHTTPResponse): return self._cookies -def json(body, status=200, headers=None, +def json(body, status=200, headers=None, content_type="application/json", **kwargs): """ Returns response object with body in json format.