Fixers

Warning

Deprecated since version 0.15: ProxyFix has moved to werkzeug.middleware.proxy_fix. All other code in this module is deprecated and will be removed in version 1.0.

New in version 0.5.

This module includes various helpers that fix web server behavior.

class werkzeug.contrib.fixers.ProxyFix(*args, **kwargs)

Deprecated since version 0.15: werkzeug.contrib.fixers.ProxyFix has moved to werkzeug.middleware.proxy_fix. This import will be removed in 1.0.

class werkzeug.contrib.fixers.CGIRootFix(app, app_root='/')

Wrap the application in this middleware if you are using FastCGI or CGI and you have problems with your app root being set to the CGI script’s path instead of the path users are going to visit.

Parameters:
  • app – the WSGI application
  • app_root – Defaulting to '/', you can set this to something else if your app is mounted somewhere else.

Deprecated since version 0.15: This middleware will be removed in version 1.0.

Changed in version 0.9: Added app_root parameter and renamed from LighttpdCGIRootFix.

class werkzeug.contrib.fixers.PathInfoFromRequestUriFix(app)

On windows environment variables are limited to the system charset which makes it impossible to store the PATH_INFO variable in the environment without loss of information on some systems.

This is for example a problem for CGI scripts on a Windows Apache.

This fixer works by recreating the PATH_INFO from REQUEST_URI, REQUEST_URL, or UNENCODED_URL (whatever is available). Thus the fix can only be applied if the webserver supports either of these variables.

Parameters: app – the WSGI application

Deprecated since version 0.15: This middleware will be removed in version 1.0.

class werkzeug.contrib.fixers.HeaderRewriterFix(app, remove_headers=None, add_headers=None)

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')])
Parameters:
  • app – the WSGI application
  • remove_headers – a sequence of header keys that should be removed.
  • add_headers – a sequence of (key, value) tuples that should be added.

Deprecated since version 0.15: This middleware will be removed in 1.0.

class werkzeug.contrib.fixers.InternetExplorerFix(app, fix_vary=True, fix_attach=True)

This middleware fixes a couple of bugs with Microsoft Internet Explorer. Currently the following fixes are applied:

  • removing of Vary headers for unsupported mimetypes which causes troubles with caching. Can be disabled by passing fix_vary=False to the constructor. see: https://support.microsoft.com/en-us/help/824847
  • removes offending headers to work around caching bugs in Internet Explorer if Content-Disposition is set. Can be disabled by passing fix_attach=False to the constructor.

If it does not detect affected Internet Explorer versions it won’t touch the request / response.

Deprecated since version 0.15: This middleware will be removed in 1.0.

© 2007–2020 Pallets
Licensed under the BSD 3-clause License.
https://werkzeug.palletsprojects.com/en/0.16.x/contrib/fixers/