Hello! On Fri, Aug 29, 2014 at 01:51:55AM +0100, Nick Kew wrote:
> I have a filter that may want to rewrite request bodies. > > Stream-editing an nginx chain is straightforward enough > (the equivalent output filter works fine). > But as I understand it, I need to cater for a case where > a request body is in r->request_body->temp_file. > Assuming it's there for a reason, I thought the least-bad > approach would be to stream-edit it to another tempfile > and switch r->request_body->temp_file to that. > > However, that approach appears to be pushing against > nginx's tempfile handling, from the moment I look at > ngx_create_temp_file and realise the amount of preparation > required to set up a path and file before calling it. > > Will Bad Things happen if I simplify by using a system > call like mkstemp and then just substitute file->fd > in nginx's temp_file struct? This will likely break client_body_in_file_only, see http://nginx.org/r/client_body_in_file_only. Not to mention that mkstemp() won't work on win32, and you'll have to unlink files yourself then. In either case, you may want to consider using request body filters instead, as recently discussed here: http://mailman.nginx.org/pipermail/nginx-devel/2014-August/005781.html Reading and then writing temorary files will be suboptimal. And replacing r->request_body->temp_file, even if you'll be able to do it properly, will likely result in your module being broken during further nginx development. -- Maxim Dounin http://nginx.org/ _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel