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 removedin version 1.0.
New in version 0.5.
This module includes various helpers that fix web server behavior.
Deprecated since version 0.15: werkzeug.contrib.fixers.ProxyFix
has moved towerkzeug.middleware.proxy_fix
. This import will beremoved in 1.0.
- class
werkzeug.contrib.fixers.
CGIRootFix
(app, app_root='/') - Wrap the application in this middleware if you are using FastCGIor CGI and you have problems with your app root being set to the CGIscript’s path instead of the path users are going to visit.
Parameters:
- app – the WSGI application
- app_root – Defaulting to
'/'
, you can set this tosomething 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 fromLighttpdCGIRootFix
.
- class
werkzeug.contrib.fixers.
PathInfoFromRequestUriFix
(app) - On windows environment variables are limited to the system charsetwhich makes it impossible to store the PATH_INFO variable in theenvironment 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 thefix can only be applied if the webserver supports either of thesevariables.
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. Thisis for example useful to remove the Date header from responses if youare using a server that adds that header, no matter if it’s present ornot 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 beremoved.
- add_headers – a sequence of
(key, value)
tuples that shouldbe 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 InternetExplorer. Currently the following fixes are applied:
- removing of Vary headers for unsupported mimetypes whichcauses 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 inInternet Explorer if Content-Disposition is set. Can bedisabled by passing
fix_attach=False
to the constructor.If it does not detect affected Internet Explorer versions it won’t touchthe request / response.
- removing of Vary headers for unsupported mimetypes whichcauses troubles with caching. Can be disabled by passing
Deprecated since version 0.15: This middleware will be removed in 1.0.