Browse Source

Fixed mime type of json to application/json

version-14
Anand Doshi 11 years ago
parent
commit
8dcb89ccfc
2 changed files with 8 additions and 12 deletions
  1. +5
    -9
      frappe/utils/response.py
  2. +3
    -3
      frappe/website/render.py

+ 5
- 9
frappe/utils/response.py View File

@@ -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


+ 3
- 3
frappe/website/render.py View File

@@ -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



Loading…
Cancel
Save