python - Django with mod_wsgi and gzip -
i using django rest server. suppose post contains json should parse. client salesforce server gzipping request.
to request inflated, use in vhost: setinputfilter deflate
almost looks fine, when read request.body or request.read(16000) - input pretty small - see chopped response (5 characters missing).
any suggestions start debugging?
technically wsgi specification doesn't support concept of mutating input filters middleware, or within underlying web server.
the specific issue mutating input filters change amount of request content, not change content_length value in wsgi environ dictionary.
the wsgi specification says valid wsgi application allowed read content_length bytes request content. consequence, in case of compressed request content, final request size end being greater content_length specifies, web framework truncate request input before data read.
you can find details issue in:
although changes in specification pushed for, nothing ever happened.
to work around problem, need implement wsgi middleware wrap around django application, if detects way of headers passed, original content had been compressed, know apache decompressed it, read request content until reach end of stream marker, ignoring content_length, before passing request django. having done that, change content_length , substitute wsgi.input replacement stream returns read content.
because content size quite large , of unknown size, reading memory not idea. therefore want read in block @ time , write out temporary file. wsgi.input replaced open file handle on temporary file , content_length replaced final size of file.
if search on mod_wsgi archives on google groups, should find prior discussions on , perhaps example code.
Comments
Post a Comment