filer.server.backends.nginx: 15 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/filer/server/backends/nginx.py

Stats: 0 executed, 13 missed, 2 excluded, 14 ignored

  1. #-*- coding: utf-8 -*-
  2. from django.http import HttpResponse
  3. from filer.server.backends.base import ServerBase
  4. class NginxXAccelRedirectServer(ServerBase):
  5. """
  6. This returns a response with only headers set, so that nginx actually does
  7. the serving
  8. """
  9. def __init__(self, location, nginx_location):
  10. """
  11. nginx_location
  12. """
  13. self.location = location
  14. self.nginx_location = nginx_location
  15. def get_nginx_location(self, path):
  16. return path.replace(self.location, self.nginx_location)
  17. def serve(self, request, file_obj, **kwargs):
  18. # we should not use get_mimetype() here, because it tries to access the file in the filesystem.
  19. #response = HttpResponse(mimetype=self.get_mimetype(file.path))
  20. response = HttpResponse()
  21. del response['Content-Type']
  22. nginx_path = self.get_nginx_location(file_obj.path)
  23. response['X-Accel-Redirect'] = nginx_path
  24. self.default_headers(request=request, response=response, file_obj=file_obj, **kwargs)
  25. return response