Hi,
I am working on an nginx module, that has flow:

receive user request -> parse request -> read local file -> process file -> 
response to client

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

receive user request -> parse request -> read local file -> process file -> 
save the processed file to temp file -> response to client


I use this code to write file:=20


   ngx_temp_file_t *tf;
           tf =ngx_pcalloc(r->pool, sizeof (ngx_temp_file_t));
           tf->file.fd = NGX_INVALID_FILE;
           tf->file.log = nlog;
           tf->path = clcf->client_body_temp_path;
           tf->pool = r->pool;
           tf->persistent = 1;
           rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool, tf->=
persistent, tf->clean, tf->access);
           ngx_write_chain_to_file(&tf->file, m->chain, m->content_length,=
r->pool);


File can be written into temporary file with following name:

-rw-------  1 root root  455712 Sep 23 13:58 0000000001
-rw-------  1 root root  455712 Sep 23 13:58 0000000002
-rw-------  1 root root 2748936 Sep 23 13:58 0000000003
-rw-------  1 root root 2831656 Sep 23 13:58 0000000004
-rw-------  1 root root 2826016 Sep 23 13:58 0000000005
-rw-------  1 root root 1786000 Sep 23 13:58 0000000006

But I cannot read from it. It seems like content of these file is not just =
(or not enough) content that user browser receive.
Let say If nginx receive user request: http://server.com/document.txt?type=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.
Please show me what I am doing wrong on this.

Thanks,

-
Hung
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to