1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

[soc2009/http-wsgi-improvments] `HttpResponseSendFile` now works (again?) using the X-SendFile header under the wsgi handler. refs #2131

Tests for other headers (and mod_python) are underway.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/http-wsgi-improvements@11284 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Chris Cahoon 2009-07-21 20:46:49 +00:00
parent 94a94bee3b
commit c6322f0096

View File

@ -240,14 +240,16 @@ class WSGIHandler(base.BaseHandler):
response_headers = [(str(k), str(v)) for k, v in response.items()] response_headers = [(str(k), str(v)) for k, v in response.items()]
for c in response.cookies.values(): for c in response.cookies.values():
response_headers.append(('Set-Cookie', str(c.output(header='')))) response_headers.append(('Set-Cookie', str(c.output(header=''))))
start_response(status, response_headers)
if isinstance(response, http.HttpResponseSendFile): if isinstance(response, http.HttpResponseSendFile):
if settings.HTTPRESPONSE_SENDFILE_METHOD: if settings.HTTPRESPONSE_SENDFILE_METHOD:
response[settings.HTTPRESPONSE_SENDFILE_METHOD] = response.sendfile_filename response_headers.append((settings.HTTPRESPONSE_SENDFILE_METHOD,
response.sendfile_filename))
elif 'wsgi.file_wrapper' in environ: elif 'wsgi.file_wrapper' in environ:
filelike = open(response.sendfile_filename, 'rb') filelike = open(response.sendfile_filename, 'rb')
return environ['wsgi.file_wrapper'](filelike, return environ['wsgi.file_wrapper'](filelike,
response.block_size) response.block_size)
start_response(status, response_headers)
return response return response