From 8dcb89ccfc9da6c4079bd540ae5bf9a954e2895b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 13 Mar 2014 14:48:34 +0530 Subject: [PATCH] Fixed mime type of json to application/json --- frappe/utils/response.py | 14 +++++--------- frappe/website/render.py | 6 +++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/frappe/utils/response.py b/frappe/utils/response.py index f137145d42..babd8a2f21 100644 --- a/frappe/utils/response.py +++ b/frappe/utils/response.py @@ -39,19 +39,15 @@ def build_response(response_type=None): def as_csv(): response = Response() - response.headers["Content-Type"] = \ - "text/csv; charset: utf-8" - response.headers["Content-Disposition"] = \ - "attachment; filename=%s.csv" % frappe.response['doctype'].replace(' ', '_') + response.headers["Content-Type"] = "text/csv; charset: utf-8" + response.headers["Content-Disposition"] = "attachment; filename=%s.csv" % frappe.response['doctype'].replace(' ', '_') response.data = frappe.response['result'] return response def as_raw(): response = Response() - response.headers["Content-Type"] = \ - mimetypes.guess_type(frappe.response['filename'])[0] or "application/unknown" - response.headers["Content-Disposition"] = \ - "filename=%s" % frappe.response['filename'].replace(' ', '_') + response.headers["Content-Type"] = mimetypes.guess_type(frappe.response['filename'])[0] or "application/unknown" + response.headers["Content-Disposition"] = "filename=%s" % frappe.response['filename'].replace(' ', '_') response.data = frappe.response['filecontent'] return response @@ -59,7 +55,7 @@ def as_json(): make_logs() cleanup_docs() response = Response() - response.headers["Content-Type"] = "text/json; charset: utf-8" + response.headers["Content-Type"] = "application/json; charset: utf-8" response = gzip(json.dumps(frappe.local.response, default=json_handler, separators=(',',':')), response=response) return response diff --git a/frappe/website/render.py b/frappe/website/render.py index c82d6a8d98..1f6022c86b 100644 --- a/frappe/website/render.py +++ b/frappe/website/render.py @@ -93,15 +93,15 @@ def resolve_path(path): def set_content_type(response, data, path): if isinstance(data, dict): - response.headers[b"Content-Type"] = b"application/json; charset: utf-8" + response.headers["Content-Type"] = "application/json; charset: utf-8" data = json.dumps(data) return data - response.headers[b"Content-Type"] = b"text/html; charset: utf-8" + response.headers["Content-Type"] = "text/html; charset: utf-8" if "." in path and not path.endswith(".html"): content_type, encoding = mimetypes.guess_type(path) - response.headers[b"Content-Type"] = content_type.encode("utf-8") + response.headers["Content-Type"] = content_type.encode("utf-8") return data