Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes


Detailed Description

This middleware can remove response headers and add others.  This
is for example useful to remove the `Date` header from responses if you
are using a server that adds that header, no matter if it's present or
not or to add `X-Powered-By` headers::

    app = HeaderRewriterFix(app, remove_headers=['Date'],
                            add_headers=[('X-Powered-By', 'WSGI')])

:param app: the WSGI application
:param remove_headers: a sequence of header keys that should be
:param add_headers: a sequence of ``(key, value)`` tuples that should
                    be added.

Definition at line 109 of file

Constructor & Destructor Documentation

def (   self,
  remove_headers = None,
  add_headers = None 

Definition at line 125 of file

00126     def __init__(self, app, remove_headers=None, add_headers=None):
00127 = app
00128         self.remove_headers = set(x.lower() for x in (remove_headers or ()))
00129         self.add_headers = list(add_headers or ())

Member Function Documentation

def (   self,

Definition at line 130 of file

00131     def __call__(self, environ, start_response):
00132         def rewriting_start_response(status, headers, exc_info=None):
00133             new_headers = []
00134             for key, value in headers:
00135                 if key.lower() not in self.remove_headers:
00136                     new_headers.append((key, value))
00137             new_headers += self.add_headers
00138             return start_response(status, new_headers, exc_info)
00139         return, rewriting_start_response)

Member Data Documentation

Definition at line 128 of file

Definition at line 126 of file

Definition at line 127 of file

The documentation for this class was generated from the following file: