Parcourir la source

Add provision to set http status code using frappe.local.response.http_status_code

version-14
Pratik Vyas il y a 11 ans
Parent
révision
c5da29e16d
1 fichiers modifiés avec 4 ajouts et 0 suppressions
  1. +4
    -0
      frappe/utils/response.py

+ 4
- 0
frappe/utils/response.py Voir le fichier

@@ -58,6 +58,10 @@ def as_raw():
def as_json(): def as_json():
make_logs() make_logs()
response = Response() response = Response()
if frappe.local.response.http_status_code:
response.status_code = frappe.local.response['http_status_code']
del frappe.local.response['http_status_code']

response.headers[b"Content-Type"] = b"application/json; charset: utf-8" response.headers[b"Content-Type"] = b"application/json; charset: utf-8"
response = gzip(json.dumps(frappe.local.response, default=json_handler, separators=(',',':')), response = gzip(json.dumps(frappe.local.response, default=json_handler, separators=(',',':')),
response=response) response=response)


Chargement…
Annuler
Enregistrer