企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Fixers 0.5 新版功能. This module includes various helpers that fix bugs in web servers. They maybe necessary for some versions of a buggy web server but not others. We tryto stay updated with the status of the bugs as good as possible but you haveto make sure whether they fix the problem you encounter. If you notice bugs in webservers not fixed in this module considercontributing a patch. *class *werkzeug.contrib.fixers.CGIRootFix(*app*, *app_root='/'*) Wrap the application in this middleware if you are using FastCGI or CGIand you have problems with your app root being set to the cgi script's pathinstead of the path users are going to visit 在 0.9 版更改: Added app_root parameter and renamed from LighttpdCGIRootFix. <table class="docutils field-list" frame="void" rules="none"><col class="field-name"/><col class="field-body"/><tbody valign="top"><tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first last simple"><li><strong>app</strong> – the WSGI application</li><li><strong>app_root</strong> – Defaulting to <tt class="docutils literal"><span class="pre">'/'</span></tt>, you can set this to something elseif your app is mounted somewhere else.</li></ul></td></tr></tbody></table> *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. | 参数: | **app** – the WSGI application | |-----|-----| *class *werkzeug.contrib.fixers.ProxyFix(*app*, *num_proxies=1*) This middleware can be applied to add HTTP proxy support to anapplication that was not designed with HTTP proxies in mind. Itsets REMOTE_ADDR, HTTP_HOST from X-Forwarded headers. If you have more than one proxy server in front of your app, setnum_proxies accordingly. Do not use this middleware in non-proxy setups for security reasons. The original values of REMOTE_ADDR and HTTP_HOST are stored inthe WSGI environment as werkzeug.proxy_fix.orig_remote_addr andwerkzeug.proxy_fix.orig_http_host. <table class="docutils field-list" frame="void" rules="none"><col class="field-name"/><col class="field-body"/><tbody valign="top"><tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first last simple"><li><strong>app</strong> – the WSGI application</li><li><strong>num_proxies</strong> – the number of proxy servers in front of the app.</li></ul></td></tr></tbody></table> get_remote_addr(*forwarded_for*) Selects the new remote addr from the given list of ips inX-Forwarded-For. By default it picks the one that the num_proxiesproxy server provides. Before 0.9 it would always pick the first. 0.8 新版功能. *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')]) ~~~ <table class="docutils field-list" frame="void" rules="none"><col class="field-name"/><col class="field-body"/><tbody valign="top"><tr class="field-odd field"><th class="field-name">参数:</th><td class="field-body"><ul class="first last simple"><li><strong>app</strong> – the WSGI application</li><li><strong>remove_headers</strong> – a sequence of header keys that should beremoved.</li><li><strong>add_headers</strong> – a sequence of <tt class="docutils literal"><span class="pre">(key,</span> <span class="pre">value)</span></tt> tuples that shouldbe added.</li></ul></td></tr></tbody></table> *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 passingfix_vary=False to the constructor.see: [http://support.microsoft.com/kb/824847/en-us](http://support.microsoft.com/kb/824847/en-us) - 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.