Skip to content

Commit 8f29230

Browse files
Merge branch 'release/4.6.5'
2 parents 3781411 + 2068d9e commit 8f29230

9 files changed

+282
-64
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
==================
2+
WSGIChunkedRequest
3+
==================
4+
5+
:Description: Enabled support for chunked request content.
6+
:Syntax: ``WSGIChunkedRequest On|Off``
7+
:Default: ``WSGIChunkedRequest Off``
8+
:Context: server config, virtual host, directory, .htaccess
9+
10+
The WSGIChunkedRequest directive can be used to enable support for chunked
11+
request content. Rather than Apache rejecting a request using chunked
12+
request content, it will be allowed to pass through.
13+
14+
Do note however that WSGI is technically incapable of supporting chunked
15+
request content without all chunked request content having to be first read
16+
in and buffered. This is because WSGI requires ``CONTENT_LENGTH`` be set
17+
when there is any request content.
18+
19+
In mod_wsgi no buffering is done. Thus, to be able to read the request
20+
content in the case of a chunked transfer encoding, you need to step
21+
outside of the WSGI specification and do things it says you aren't meant to.
22+
23+
You have two choices for how you can do this. The first choice you have
24+
is to call ``read()`` on ``wsgi.input`` but not supply any argument at all.
25+
This will cause all request content to be read in and returned.
26+
27+
The second is to loop on calling ``read()`` on ``wsgi.input`` with a set
28+
block size passed as argument and do this until ``read()`` returns an empty
29+
string.
30+
31+
Because both calling methods are not allowed under WSGI specification, in
32+
using these your code will not technically be portable to other WSGI hosting
33+
mechanisms, although if those other WSGI servers support it, you will be
34+
okay.
35+
36+
That all said, although technically not permitted by the WSGI specification,
37+
some WSGI frameworks do now incoporate support for handling chunked request
38+
content, as well as where compressed request content is expanded by the web
39+
server such that ``CONTENT_LENGTH`` is no longer accurate. The required
40+
behaviour is enabled in these frameworks by the WSGI server passing through
41+
the non standard ``wsgi.input_terminated`` key set as ``True`` in the per
42+
request WSGI ``environ`` dictionary. When this is done the web frameworks
43+
will always read all available input and ignore ``CONTENT_LENGTH``.
44+
45+
Because mod_wsgi guarantees that an empty string is returned when all input
46+
is exhausted, it will will always set this flag.
47+
48+
It is known that Flask/Werkzeug supports the ``wsgi.input_terminated`` flag.

docs/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Configuration
1212
configuration-directives/WSGIAuthUserScript
1313
configuration-directives/WSGICallableObject
1414
configuration-directives/WSGICaseSensitivity
15+
configuration-directives/WSGIChunkedRequest
1516
configuration-directives/WSGIDaemonProcess
1617
configuration-directives/WSGIImportScript
1718
configuration-directives/WSGILazyInitialization

docs/release-notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Release Notes
55
.. toctree::
66
:maxdepth: 2
77

8+
release-notes/version-4.6.5
89
release-notes/version-4.6.4
910
release-notes/version-4.6.3
1011
release-notes/version-4.6.2

docs/release-notes/version-4.6.5.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=============
2+
Version 4.6.5
3+
=============
4+
5+
Version 4.6.5 of mod_wsgi can be obtained from:
6+
7+
https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.6.5
8+
9+
Bugs Fixed
10+
----------
11+
12+
* When running ``mod_wsgi-express`` and serving up static files from the
13+
document root, and the WSGI application was mounted at a sub URL using
14+
``--mount-point``, the static files in the document root outside of the
15+
mount point for the WSGI application would no longer be accessible.
16+
17+
* If no system mime types file can be found, fall back to ``/dev/null``
18+
so that Apache can still at least start up.
19+
20+
Features Changed
21+
----------------
22+
23+
* On macOS, use ``/var/tmp`` as default parent directory for server root
24+
directory rather than value of ``$TMPDIR``. The latter can produce a
25+
path which is too long and UNIX socket cannot be written there.
26+
27+
New Features
28+
------------
29+
30+
* Now possible to use ``mod_wsgi-express`` in an a ``zipapp`` created using
31+
``shiv``. This entailed a special workaround to detect when ``shiv`` was
32+
used, so that the unpacked ``site-packages`` directory could be added to
33+
the Python module search path for ``mod_wsgi-express``.

docs/user-guides/access-control-mechanisms.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ only one small part of them. This will result in a lot of memory being used
126126
in the Apache child processes just to support the auth provider.
127127

128128
If mod_authn_alias is being loaded into Apache, then an aliased auth
129-
%rovider can also be defined::
129+
provider can also be defined::
130130

131131
<AuthnProviderAlias wsgi django>
132132
WSGIAuthUserScript /usr/local/django/mysite/apache/auth.wsgi \
@@ -136,8 +136,13 @@ If mod_authn_alias is being loaded into Apache, then an aliased auth
136136
WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
137137

138138
<Directory /usr/local/django/mysite/apache>
139-
Order deny,allow
140-
Allow from all
139+
<IfVersion < 2.4>
140+
Order allow,deny
141+
Allow from all
142+
</IfVersion>
143+
<IfVersion >= 2.4>
144+
Require all granted
145+
</IfVersion>
141146

142147
WSGIApplicationGroup django
143148

docs/user-guides/configuration-guidelines.rst

Lines changed: 96 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,20 @@ within that directory can be used. To do this the Directory directive must
5050
be used::
5151

5252
<Directory /usr/local/wsgi/scripts>
53-
Order allow,deny
54-
Allow from all
53+
<IfVersion < 2.4>
54+
Order allow,deny
55+
Allow from all
56+
</IfVersion>
57+
<IfVersion >= 2.4>
58+
Require all granted
59+
</IfVersion>
5560
</Directory>
5661

57-
Note that Apache access control directives such as Order and Allow should
58-
nearly always be applied to Directory and never to a Location. Adding them
59-
to a Location would not be regarded as best practice and would potentially
60-
weaken the security of your Apache server, especially where the Location
61-
was for '/'.
62+
Note that Apache access control directives such as Order and Allow, or
63+
Require in the case of Apache 2.4 or newer, should nearly always be applied
64+
to Directory and never to a Location. Adding them to a Location would not
65+
be regarded as best practice and would potentially weaken the security of
66+
your Apache server, especially where the Location was for '/'.
6267

6368
As for CGI scripts and the ScriptAlias directive, it is not necessary to
6469
have used the Options directive to enable the ExecCGI directive. This is
@@ -117,8 +122,13 @@ specific URLs. The equivalent such configuration for::
117122
WSGIScriptAlias /wsgi/ /usr/local/wsgi/scripts/
118123

119124
<Directory /usr/local/wsgi/scripts>
120-
Order allow,deny
121-
Allow from all
125+
<IfVersion < 2.4>
126+
Order allow,deny
127+
Allow from all
128+
</IfVersion>
129+
<IfVersion >= 2.4>
130+
Require all granted
131+
</IfVersion>
122132
</Directory>
123133

124134
using the Alias directive would be::
@@ -130,8 +140,13 @@ using the Alias directive would be::
130140

131141
SetHandler wsgi-script
132142

133-
Order allow,deny
134-
Allow from all
143+
<IfVersion < 2.4>
144+
Order allow,deny
145+
Allow from all
146+
</IfVersion>
147+
<IfVersion >= 2.4>
148+
Require all granted
149+
</IfVersion>
135150
</Directory>
136151

137152
The additional steps required in this case are to enable the ability to
@@ -151,8 +166,13 @@ resource types based on resource extension::
151166
AddHandler cgi-script .cgi
152167
AddHandler wsgi-script .wsgi
153168

154-
Order allow,deny
155-
Allow from all
169+
<IfVersion < 2.4>
170+
Order allow,deny
171+
Allow from all
172+
</IfVersion>
173+
<IfVersion >= 2.4>
174+
Require all granted
175+
</IfVersion>
156176
</Directory>
157177

158178
For whatever extension you use to identify a WSGI script file, ensure that
@@ -177,8 +197,13 @@ option and MultiviewsMatch directive::
177197
AddHandler cgi-script .cgi
178198
AddHandler wsgi-script .wsgi
179199

180-
Order allow,deny
181-
Allow from all
200+
<IfVersion < 2.4>
201+
Order allow,deny
202+
Allow from all
203+
</IfVersion>
204+
<IfVersion >= 2.4>
205+
Require all granted
206+
</IfVersion>
182207
</Directory>
183208

184209
Adding of MultiViews in this instance and allowing multiviews to match
@@ -201,8 +226,13 @@ the directory. To enable directory browsing add the Indexes option::
201226
AddHandler cgi-script .cgi
202227
AddHandler wsgi-script .wsgi
203228

204-
Order allow,deny
205-
Allow from all
229+
<IfVersion < 2.4>
230+
Order allow,deny
231+
Allow from all
232+
</IfVersion>
233+
<IfVersion >= 2.4>
234+
Require all granted
235+
</IfVersion>
206236
</Directory>
207237

208238
If a directory index page is enabled, it may refer to either a static file,
@@ -219,8 +249,13 @@ designate what should be used for the index page::
219249
AddHandler cgi-script .cgi
220250
AddHandler wsgi-script .wsgi
221251

222-
Order allow,deny
223-
Allow from all
252+
<IfVersion < 2.4>
253+
Order allow,deny
254+
Allow from all
255+
</IfVersion>
256+
<IfVersion >= 2.4>
257+
Require all granted
258+
</IfVersion>
224259
</Directory>
225260

226261
Using AddHandler or SetHandler to configure a WSGI application can also
@@ -238,8 +273,13 @@ Options directive by listing ExecCGI::
238273
Options ExecCGI MultiViews Indexes
239274
MultiviewsMatch Handlers
240275

241-
Order allow,deny
242-
Allow from all
276+
<IfVersion < 2.4>
277+
Order allow,deny
278+
Allow from all
279+
</IfVersion>
280+
<IfVersion >= 2.4>
281+
Require all granted
282+
</IfVersion>
243283
</Directory>
244284

245285
This done, the '.htaccess' file could then contain::
@@ -388,15 +428,25 @@ which should be served in this way::
388428
Alias /media/ /usr/local/wsgi/static/media/
389429

390430
<Directory /usr/local/wsgi/static>
391-
Order deny,allow
392-
Allow from all
431+
<IfVersion < 2.4>
432+
Order allow,deny
433+
Allow from all
434+
</IfVersion>
435+
<IfVersion >= 2.4>
436+
Require all granted
437+
</IfVersion>
393438
</Directory>
394439

395440
WSGIScriptAlias / /usr/local/wsgi/scripts/myapp.wsgi
396441

397442
<Directory /usr/local/wsgi/scripts>
398-
Order allow,deny
399-
Allow from all
443+
<IfVersion < 2.4>
444+
Order allow,deny
445+
Allow from all
446+
</IfVersion>
447+
<IfVersion >= 2.4>
448+
Require all granted
449+
</IfVersion>
400450
</Directory>
401451

402452
When listing the directives, list those for more specific URLs first. In
@@ -465,8 +515,13 @@ the WSGIApplicationGroup directive::
465515
<Directory /usr/local/wsgi/scripts>
466516
WSGIApplicationGroup admin-scripts
467517

468-
Order allow,deny
469-
Allow from all
518+
<IfVersion < 2.4>
519+
Order allow,deny
520+
Allow from all
521+
</IfVersion>
522+
<IfVersion >= 2.4>
523+
Require all granted
524+
</IfVersion>
470525
</Directory>
471526

472527
The argument to the WSGIApplicationGroup directive can in general be any
@@ -560,17 +615,27 @@ specific WSGI applications to execute within that daemon process::
560615
Alias /media/ /usr/local/wsgi/static/media/
561616

562617
<Directory /usr/local/wsgi/static>
563-
Order deny,allow
564-
Allow from all
618+
<IfVersion < 2.4>
619+
Order allow,deny
620+
Allow from all
621+
</IfVersion>
622+
<IfVersion >= 2.4>
623+
Require all granted
624+
</IfVersion>
565625
</Directory>
566626

567627
WSGIScriptAlias / /usr/local/wsgi/scripts/myapp.wsgi
568628
WSGIProcessGroup www.site.com
569629

570630
<Directory /usr/local/wsgi/scripts>
571631

572-
Order allow,deny
573-
Allow from all
632+
<IfVersion < 2.4>
633+
Order allow,deny
634+
Allow from all
635+
</IfVersion>
636+
<IfVersion >= 2.4>
637+
Require all granted
638+
</IfVersion>
574639
</Directory>
575640

576641
Where Apache has been started as the ``root`` user, the daemon processes

0 commit comments

Comments
 (0)