This is not a Django issue. This is a limitation of the WSGI specification itself to the extent that the WSGI specification prohibits the use of content with the requested request, which requires the value CONTENT_LENGTH for the request.
When using mod_wsgi, there is a switch to enable non-standard support for the content with the requested request, but this means that your application is not compatible with WSGI, plus it will require a special web application or WSGI wrapper, since it is still not going to work with Django.
An option in mod_wsgi for the allowed content of the request:
WSGIChunkedRequest On
Your WSGI shell must call wsgi.input.read () to get all the content, create an instance of StringIO with it and use it to replace wsgi.input, and then add a new CONTENT_LENGTH value to the environment with the actual length before calling the wrapped application.
Note that this is dangerous because you do not know how much data is being sent.
Which client do you use anyway that only supports batch request content?
UPDATE 1
Your code has been broken for many reasons. You should use something like:
import StringIO django_application = get_wsgi_application() def application(environ, start_response): if environ.get("mod_wsgi.input_chunked") == "1": stream = environ["wsgi.input"] data = stream.read() environ["CONTENT_LENGTH"] = str(len(data)) environ["wsgi.input"] = StringIO.StringIO(data) return django_application(environ, start_response)
Please note that this will not help with the contents of the gzip'd request. To do this, you will need an additional check to see when the content encoding has been compressed, and then do the same as above. This is because when the data is not compressed by Apache, the length of the content changes, and you need to recount it.
Graham dumpleton
source share