To have an application I am developing, the consumer submits a gzipped HTTP Publish request (content-encoding: GZIP) with multipart form data (content-type: multipart/form-data). I personally use mod_deflate being an input filter to decompress and also the web request is processed in Django via mod_wsgi.
Generally, things are fine. But for several demands (deterministic), there's almost one minute lag from request to response. Analysis implies that the processing in django is performed immediately, however the response in the server stalls. When the request isn't GZIPed, all is effective.
Observe that to handle a glitch in mod_wsgi, I set content-length towards the uncompressed mesage size.
Has anybody encounter this issue? It is possible to method to easily debug apache because it processes reactions?
What glitch would you believe is available in mod_wsgi?
The easy simple fact is the fact that WSGI 1. does not support mutating input filters which alter the content entire request content. Thus technically you cannot use mod_deflate in Apache for request content when utilizing WSGI 1.. Your setting this content length to become a value apart from the particular size is probably likely to stuff up operation of mod_deflate.
If you wish to have the ability to handle compressed request content you have to step outdoors of WSGI 1. specs and employ non standard code.
It is best to possess a read of:
This describes this issue and also the information on it.
I'd greatly suggest you are taking this problem to the state mod_wsgi mailing list for discussion about how exactly you have to write your code. If though you're using among the Python frameworks however, you're most likely likely to be restricted in you skill because they will implement WSGI 1. in which you can't do that.
From discussion on mod_wsgi list, the initial WSGI application ought to be covered with following WSGI middleware. This can only focus on WSGI plugs that really offer an empty string as finish sentinel for input, a thing that WSGI 1. does not require. This will possibly simply be employed for small uploads as things are read into memory. If need large compressed uploads, then data when gathered ought to be written to personal files rather.
class Wrapper: def __init__(self, application): self.__application = application def __call__(self, environ, start_response): if environ.get('HTTP_CONTENT_ENCODING', '') == 'gzip': buffer = cStringIO.StringIO() input = environ['wsgi.input'] blksize = 8192 length = 0 data = input.read(blksize) buffer.write(data) length += len(data) while data: data = input.read(blksize) buffer.write(data) length += len(data) buffer = cStringIO.StringIO(buffer.getvalue()) environ['wsgi.input'] = buffer environ['CONTENT_LENGTH'] = length return self.__application(environ, start_response) application = Wrapper(original_wsgi_application_callable)