Merge pull request #5164 from achillesrasquinha/py3
Fixed byte response headers
This commit is contained in:
commit
d2bfd2c5fe
1 changed files with 5 additions and 5 deletions
|
|
@ -52,14 +52,14 @@ def as_csv():
|
|||
response = Response()
|
||||
response.mimetype = 'text/csv'
|
||||
response.charset = 'utf-8'
|
||||
response.headers[b"Content-Disposition"] = ("attachment; filename=\"%s.csv\"" % frappe.response['doctype'].replace(' ', '_')).encode("utf-8")
|
||||
response.headers["Content-Disposition"] = ("attachment; filename=\"%s.csv\"" % frappe.response['doctype'].replace(' ', '_')).encode("utf-8")
|
||||
response.data = frappe.response['result']
|
||||
return response
|
||||
|
||||
def as_raw():
|
||||
response = Response()
|
||||
response.mimetype = frappe.response.get("content_type") or mimetypes.guess_type(frappe.response['filename'])[0] or b"application/unknown"
|
||||
response.headers[b"Content-Disposition"] = ("filename=\"%s\"" % frappe.response['filename'].replace(' ', '_')).encode("utf-8")
|
||||
response.mimetype = frappe.response.get("content_type") or mimetypes.guess_type(frappe.response['filename'])[0] or "application/unknown"
|
||||
response.headers["Content-Disposition"] = ("filename=\"%s\"" % frappe.response['filename'].replace(' ', '_')).encode("utf-8")
|
||||
response.data = frappe.response['filecontent']
|
||||
return response
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ def as_json():
|
|||
def as_binary():
|
||||
response = Response()
|
||||
response.mimetype = 'application/octet-stream'
|
||||
response.headers[b"Content-Disposition"] = ("filename=\"%s\"" % frappe.response['filename'].replace(' ', '_')).encode("utf-8")
|
||||
response.headers["Content-Disposition"] = ("filename=\"%s\"" % frappe.response['filename'].replace(' ', '_')).encode("utf-8")
|
||||
response.data = frappe.response['filecontent']
|
||||
return response
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ def send_private_file(path):
|
|||
# no need for content disposition and force download. let browser handle its opening.
|
||||
# response.headers.add(b'Content-Disposition', b'attachment', filename=filename.encode("utf-8"))
|
||||
|
||||
response.mimetype = mimetypes.guess_type(filename)[0] or b'application/octet-stream'
|
||||
response.mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
|
||||
|
||||
return response
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue