예제 #1
0
 def __init__(
     self,
     redirect_url,
     content_type,
     basename=None,
     expires=None,
     with_buffering=None,
     limit_rate=None,
     attachment=True,
 ):
     """Return a HttpResponse with headers for Nginx X-Accel-Redirect."""
     super(XAccelRedirectResponse, self).__init__(content_type=content_type)
     if attachment:
         self.basename = basename or url_basename(redirect_url,
                                                  content_type)
         self["Content-Disposition"] = content_disposition(self.basename)
     self["X-Accel-Redirect"] = redirect_url
     self["X-Accel-Charset"] = content_type_to_charset(content_type)
     if with_buffering is not None:
         self["X-Accel-Buffering"] = with_buffering and "yes" or "no"
     if expires:
         expire_seconds = timedelta(expires - now()).seconds
         self["X-Accel-Expires"] = expire_seconds
     elif expires is not None:  # We explicitely want it off.
         self["X-Accel-Expires"] = "off"
     if limit_rate is not None:
         self[
             "X-Accel-Limit-Rate"] = limit_rate and "%d" % limit_rate or "off"
예제 #2
0
 def __init__(self, file_path, content_type, basename=None, attachment=True):
     """Return a HttpResponse with headers for Lighttpd X-Sendfile."""
     super(XSendfileResponse, self).__init__(content_type=content_type)
     if attachment:
         self.basename = basename or os.path.basename(file_path)
         self["Content-Disposition"] = content_disposition(self.basename)
     self["X-Sendfile"] = file_path
예제 #3
0
 def __init__(self, file_path, content_type, basename=None,
              attachment=True):
     """Return a HttpResponse with headers for Apache X-Sendfile."""
     super(XSendfileResponse, self).__init__(content_type=content_type)
     if attachment:
         self.basename = basename or os.path.basename(file_path)
         self['Content-Disposition'] = content_disposition(self.basename)
     self['X-Sendfile'] = file_path
예제 #4
0
 def __init__(self, redirect_url, content_type, basename=None, expires=None,
              with_buffering=None, limit_rate=None, attachment=True):
     """Return a HttpResponse with headers for Nginx X-Accel-Redirect."""
     super(XAccelRedirectResponse, self).__init__(content_type=content_type)
     if attachment:
         self.basename = basename or url_basename(redirect_url,
                                                  content_type)
         self['Content-Disposition'] = content_disposition(self.basename)
     self['X-Accel-Redirect'] = redirect_url
     self['X-Accel-Charset'] = content_type_to_charset(content_type)
     if with_buffering is not None:
         self['X-Accel-Buffering'] = with_buffering and 'yes' or 'no'
     if expires:
         expire_seconds = timedelta(expires - now()).seconds
         self['X-Accel-Expires'] = expire_seconds
     elif expires is not None:  # We explicitely want it off.
         self['X-Accel-Expires'] = 'off'
     if limit_rate is not None:
         self['X-Accel-Limit-Rate'] = \
             limit_rate and '%d' % limit_rate or 'off'