1
0
mirror of https://github.com/etesync/server synced 2024-11-29 12:08:07 +00:00
etesync-server/django_etebase/sendfile/backends/mod_wsgi.py

18 lines
519 B
Python

from __future__ import absolute_import
from django.http import HttpResponse
from ..utils import _convert_file_to_url
def sendfile(request, filename, **kwargs):
response = HttpResponse()
response['Location'] = _convert_file_to_url(filename)
# need to destroy get_host() to stop django
# rewriting our location to include http, so that
# mod_wsgi is able to do the internal redirect
request.get_host = lambda: ''
request.build_absolute_uri = lambda location: location
return response