processing request body in files

Jeff Kaufman jefftk at
Fri Aug 8 14:44:59 UTC 2014

In ngx_pagespeed we want to handle POSTs, processing them in our nginx
module and performing an action.  This works fine for small POSTs, but
if they're too big then r->request_body->temp_file is set and the data
isn't available in memory.  Right now we just log an error, but I'd
like to fix this.

To read from that file, is it safe to just call
ngx_open_tempfile(r->request_body->temp_file->, ...) and then
ngx_read_file() until that returns 0 for EOF (like standard unix) or
an error?  Or is there something more complex we need to do?

(I've looked for existing modules that do this, but haven't found any.
I'm not finding any modules that currently do that; just ones that
issue a rename command to move r->request_body->temp_file into the
final destination.)

More information about the nginx-devel mailing list