From 71b99c8ce9afd1eabb1ee07a6b2d0d23f08dd89c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 24 Oct 2012 17:18:23 +0200 Subject: [PATCH] better unicode support for download names --- ox/django/http.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ox/django/http.py b/ox/django/http.py index 4efd0da..df73ce8 100644 --- a/ox/django/http.py +++ b/ox/django/http.py @@ -3,6 +3,7 @@ import os import mimetypes from datetime import datetime, timedelta +from urllib import quote from django.http import HttpResponse, Http404 from django.conf import settings @@ -43,7 +44,8 @@ def HttpFileResponse(path, content_type=None, filename=None): if filename: if isinstance(filename, unicode): filename = filename.encode('utf-8') - response['Content-Disposition'] = 'attachment; filename="%s"' % filename + response['Content-Disposition'] = 'attachment; filename*=UTF=8''%s' % quote(filename) + response['Expires'] = datetime.strftime(datetime.utcnow() + timedelta(days=1), "%a, %d-%b-%Y %H:%M:%S GMT") return response