Brad Clements wrote: > I am using gzipper middleware and recursive includer. > > My wsgi application serves up xslt and xml files to recent browsers, > but for older browsers it does the xslt conversion on the server using lxml. > > I have some large xml files that I want to gzip, so I've added > filter-with=gzip as appropriate to various app sections in my deploy > .ini file > > The problem I have is that when doing server-side xslt transform, > includer ends up returning gzip'd contents to lxml, leading to failure. > > I think gzipper should not gzip when returning data as part of an > 'included' request (but I guess it should gzip forwarded requests). > > I imagine there will be other middleware components that might need to > be tweaked in various ways to work correctly when being called via > includer. > > On the other hand, I do create a new environ to be used by Include so I > could adjust HTTP_ACCEPT_ENCODING with that.
That is really what you should do, declaring what you expect to receive. > But as I look at recursive.py I'm thinking that maybe Recursive.__call__ > should also accept a list of keys to delete from the original environ, > or be able to accept a completely new environ.. Currently __call__ only > accepts a dict (extra_environ) to be merged into the environ used during > Include processing. > > Though maybe passing in a completely new environ might break recursion > checking. > > What's the best way to go here? Change gzipper and other filtering > middleware to detect when it's being called by Includer, or add a > delete_keys parameter to Recursive.__call__ or just rely on > extra_environ to set certain environ variables to the empty string? I'm not particularly happy with recursive, really. Doing subrequests manually generally seems to work better. Or, if I do subrequests now, I usually use recursive just to get a handle on the root application and environ, and don't use the recursive objects. This is particularly easy with webob, as you just do: req = Request(orig_environ).copy_get() req.path_info = new_path req.remove_conditional_headers() resp = req.get_response(root_app) .remove_conditional_headers() keeps you from getting 304 responses and gzipped responses (though webob can actually decode gzip responses too using resp.decode_content(), though you probably don't want them zipped to begin with). .copy_get() copies the request environ, but also makes sure the new request is a GET and cleans out wsgi.input. Ian _______________________________________________ Paste-users mailing list [email protected] http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users
