From 8d7207420963f09f333bc21bfb935394cbe3f8b9 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Wed, 17 Dec 2014 17:28:30 +0100 Subject: [PATCH 1/2] issue 2024: response.json sets by default content-type to application/json --- gluon/globals.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gluon/globals.py b/gluon/globals.py index 7091f40c..f2c13882 100644 --- a/gluon/globals.py +++ b/gluon/globals.py @@ -626,6 +626,8 @@ class Response(Storage): return self.stream(stream, chunk_size=chunk_size, request=request) def json(self, data, default=None): + if 'Content-Type' not in self.headers: + self.headers['Content-Type'] = contenttype('.json') return json(data, default=default or custom_json) def xmlrpc(self, request, methods): From 952890d9cc4256c1628b5df01375821fa7279ab9 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Thu, 18 Dec 2014 09:34:46 +0100 Subject: [PATCH 2/2] set directly 'application/json' to avoid a call to contenttype --- gluon/globals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/globals.py b/gluon/globals.py index f2c13882..166a8f8b 100644 --- a/gluon/globals.py +++ b/gluon/globals.py @@ -627,7 +627,7 @@ class Response(Storage): def json(self, data, default=None): if 'Content-Type' not in self.headers: - self.headers['Content-Type'] = contenttype('.json') + self.headers['Content-Type'] = 'application/json' return json(data, default=default or custom_json) def xmlrpc(self, request, methods):