nginx tempfiles

Nick Kew niq at apache.org
Fri Aug 29 00:51:55 UTC 2014


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?

Or is this approach completely barking up the wrong tree?

-- 
Nick Kew



More information about the nginx-devel mailing list