Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.contrib.fixers.HeaderRewriterFix Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 app
 remove_headers
 add_headers

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
                       removed.
:param add_headers: a sequence of ``(key, value)`` tuples that should
                    be added.

Definition at line 109 of file fixers.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.contrib.fixers.HeaderRewriterFix.__init__ (   self,
  app,
  remove_headers = None,
  add_headers = None 
)

Definition at line 125 of file fixers.py.

00125 
00126     def __init__(self, app, remove_headers=None, add_headers=None):
00127         self.app = 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 MoinMoin.support.werkzeug.contrib.fixers.HeaderRewriterFix.__call__ (   self,
  environ,
  start_response 
)

Definition at line 130 of file fixers.py.

00130 
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 self.app(environ, rewriting_start_response)
00140 


Member Data Documentation

Definition at line 128 of file fixers.py.

Definition at line 126 of file fixers.py.

Definition at line 127 of file fixers.py.


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