/usr/share/doc/python-werkzeug-doc/html/contrib/fixers.html is in python-werkzeug-doc 0.10.4+dfsg1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fixers — Werkzeug 0.10.4 documentation</title>
<link rel="stylesheet" href="../_static/werkzeug.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.10.4',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Werkzeug 0.10.4 documentation" href="../index.html" />
<link rel="up" title="Contributed Modules" href="index.html" />
<link rel="next" title="WSGI Application Profiler" href="profiler.html" />
<link rel="prev" title="Iter IO" href="iterio.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="profiler.html" title="WSGI Application Profiler"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="iterio.html" title="Iter IO"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">Werkzeug 0.10.4 documentation</a> »</li>
<li><a href="index.html" accesskey="U">Contributed Modules</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-werkzeug.contrib.fixers">
<span id="fixers"></span><h1>Fixers<a class="headerlink" href="#module-werkzeug.contrib.fixers" title="Permalink to this headline">¶</a></h1>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
<p>This module includes various helpers that fix bugs in web servers. They may
be necessary for some versions of a buggy web server but not others. We try
to stay updated with the status of the bugs as good as possible but you have
to make sure whether they fix the problem you encounter.</p>
<p>If you notice bugs in webservers not fixed in this module consider
contributing a patch.</p>
<dl class="class">
<dt id="werkzeug.contrib.fixers.CGIRootFix">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.fixers.</tt><tt class="descname">CGIRootFix</tt><big>(</big><em>app</em>, <em>app_root='/'</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.fixers.CGIRootFix" title="Permalink to this definition">¶</a></dt>
<dd><p>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</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.9: </span>Added <cite>app_root</cite> parameter and renamed from <cite>LighttpdCGIRootFix</cite>.</p>
</div>
<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">Parameters:</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 else
if your app is mounted somewhere else.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="werkzeug.contrib.fixers.PathInfoFromRequestUriFix">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.fixers.</tt><tt class="descname">PathInfoFromRequestUriFix</tt><big>(</big><em>app</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.fixers.PathInfoFromRequestUriFix" title="Permalink to this definition">¶</a></dt>
<dd><p>On windows environment variables are limited to the system charset
which makes it impossible to store the <cite>PATH_INFO</cite> variable in the
environment without loss of information on some systems.</p>
<p>This is for example a problem for CGI scripts on a Windows Apache.</p>
<p>This fixer works by recreating the <cite>PATH_INFO</cite> from <cite>REQUEST_URI</cite>,
<cite>REQUEST_URL</cite>, or <cite>UNENCODED_URL</cite> (whatever is available). Thus the
fix can only be applied if the webserver supports either of these
variables.</p>
<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">Parameters:</th><td class="field-body"><strong>app</strong> – the WSGI application</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="werkzeug.contrib.fixers.ProxyFix">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.fixers.</tt><tt class="descname">ProxyFix</tt><big>(</big><em>app</em>, <em>num_proxies=1</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.fixers.ProxyFix" title="Permalink to this definition">¶</a></dt>
<dd><p>This middleware can be applied to add HTTP proxy support to an
application that was not designed with HTTP proxies in mind. It
sets <cite>REMOTE_ADDR</cite>, <cite>HTTP_HOST</cite> from <cite>X-Forwarded</cite> headers. While
Werkzeug-based applications already can use
<a class="reference internal" href="../wsgi.html#werkzeug.wsgi.get_host" title="werkzeug.wsgi.get_host"><tt class="xref py py-func docutils literal"><span class="pre">werkzeug.wsgi.get_host()</span></tt></a> to retrieve the current host even if
behind proxy setups, this middleware can be used for applications which
access the WSGI environment directly.</p>
<p>If you have more than one proxy server in front of your app, set
<cite>num_proxies</cite> accordingly.</p>
<p>Do not use this middleware in non-proxy setups for security reasons.</p>
<p>The original values of <cite>REMOTE_ADDR</cite> and <cite>HTTP_HOST</cite> are stored in
the WSGI environment as <cite>werkzeug.proxy_fix.orig_remote_addr</cite> and
<cite>werkzeug.proxy_fix.orig_http_host</cite>.</p>
<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">Parameters:</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>
<dl class="method">
<dt id="werkzeug.contrib.fixers.ProxyFix.get_remote_addr">
<tt class="descname">get_remote_addr</tt><big>(</big><em>forwarded_for</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.fixers.ProxyFix.get_remote_addr" title="Permalink to this definition">¶</a></dt>
<dd><p>Selects the new remote addr from the given list of ips in
X-Forwarded-For. By default it picks the one that the <cite>num_proxies</cite>
proxy server provides. Before 0.9 it would always pick the first.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.8.</span></p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="werkzeug.contrib.fixers.HeaderRewriterFix">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.fixers.</tt><tt class="descname">HeaderRewriterFix</tt><big>(</big><em>app</em>, <em>remove_headers=None</em>, <em>add_headers=None</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.fixers.HeaderRewriterFix" title="Permalink to this definition">¶</a></dt>
<dd><p>This middleware can remove response headers and add others. This
is for example useful to remove the <cite>Date</cite> header from responses if you
are using a server that adds that header, no matter if it’s present or
not or to add <cite>X-Powered-By</cite> headers:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">app</span> <span class="o">=</span> <span class="n">HeaderRewriterFix</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="n">remove_headers</span><span class="o">=</span><span class="p">[</span><span class="s">'Date'</span><span class="p">],</span>
<span class="n">add_headers</span><span class="o">=</span><span class="p">[(</span><span class="s">'X-Powered-By'</span><span class="p">,</span> <span class="s">'WSGI'</span><span class="p">)])</span>
</pre></div>
</div>
<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">Parameters:</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 be
removed.</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 should
be added.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="werkzeug.contrib.fixers.InternetExplorerFix">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.fixers.</tt><tt class="descname">InternetExplorerFix</tt><big>(</big><em>app</em>, <em>fix_vary=True</em>, <em>fix_attach=True</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.fixers.InternetExplorerFix" title="Permalink to this definition">¶</a></dt>
<dd><p>This middleware fixes a couple of bugs with Microsoft Internet
Explorer. Currently the following fixes are applied:</p>
<ul class="simple">
<li>removing of <cite>Vary</cite> headers for unsupported mimetypes which
causes troubles with caching. Can be disabled by passing
<tt class="docutils literal"><span class="pre">fix_vary=False</span></tt> to the constructor.
see: <a class="reference external" href="http://support.microsoft.com/kb/824847/en-us">http://support.microsoft.com/kb/824847/en-us</a></li>
<li>removes offending headers to work around caching bugs in
Internet Explorer if <cite>Content-Disposition</cite> is set. Can be
disabled by passing <tt class="docutils literal"><span class="pre">fix_attach=False</span></tt> to the constructor.</li>
</ul>
<p>If it does not detect affected Internet Explorer versions it won’t touch
the request / response.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper"><p class="logo"><a href="../index.html">
<img class="logo" src="../_static/werkzeug.png" alt="Logo"/>
</a></p><h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="index.html">Contributed Modules</a><ul>
<li>Previous: <a href="iterio.html" title="previous chapter">Iter IO</a></li>
<li>Next: <a href="profiler.html" title="next chapter">WSGI Application Profiler</a></li>
</ul></li>
</ul></li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/contrib/fixers.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
© Copyright 2011, The Werkzeug Team.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
</div>
</body>
</html>
|