<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<br>I am working on an nginx module, that has flow:<br><br><b><span class="Apple-tab-span" style="white-space:pre"> </span>receive user request -> parse request -> read local file -> process file -> response to client<br></b><br>This flow is working well. But now we have another requirement. Afer process this file and build response into ngx_chain, I want to write response content into ngx_temp_file to do another job, after that return response to client<br><br><div><span class="Apple-tab-span" style="white-space:pre"> </span><b>receive user request -> parse request -> read local file -> process file -> save the processed file to temp file -> response to client<br></b><br><br>I use this code to write file:=20<br><br><br><span class="Apple-tab-span" style="white-space: pre;"> </span> ngx_temp_file_t *tf;<br> tf =ngx_pcalloc(r->pool, sizeof (ngx_temp_file_t));<br> tf->file.fd = NGX_INVALID_FILE;<br> tf->file.log = nlog;<br> tf->path = clcf->client_body_temp_path;<br> tf->pool = r->pool;<br> tf->persistent = 1;<br> rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool, tf->=<br>persistent, tf->clean, tf->access);<br> ngx_write_chain_to_file(&tf->file, m->chain, m->content_length,=<br>r->pool);<br><br><br>File can be written into temporary file with following name:<br><br>-rw------- 1 root root 455712 Sep 23 13:58 0000000001<br>-rw------- 1 root root 455712 Sep 23 13:58 0000000002<br>-rw------- 1 root root 2748936 Sep 23 13:58 0000000003<br>-rw------- 1 root root 2831656 Sep 23 13:58 0000000004<br>-rw------- 1 root root 2826016 Sep 23 13:58 0000000005<br>-rw------- 1 root root 1786000 Sep 23 13:58 0000000006<br><br>But I cannot read from it. It seems like content of these file is not just =<br>(or not enough) content that user browser receive.<br>Let say If nginx receive user request: <a href="http://server.com/document.txt?type=">http://server.com/document.txt?type=</a>csv , our module will process the original document.txt file, process file to make it csv type, save it to ngx_temp_file, and return to client document.csv file. But the file that was saved into ngx_temp_file is not csv file.<br>Please show me what I am doing wrong on this.<br><br>Thanks,<br><br>-<br>Hung</div></body></html>