httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Horner <jeff.hor...@vanderbilt.edu>
Subject Generated spool file okay to copy after parse?
Date Thu, 07 Jul 2005 17:42:47 GMT
Hello,

I'm linking against libapreq2-2.05-dev and I'd like to know if the 
generated spool files are okay to copy after parsing the request POST 
data. Consider the following code (executed from within a request handler):

formd = apr_table_make(r->pool, APREQ_DEFAULT_NELTS);
filed = apr_table_make(r->pool, APREQ_DEFAULT_NELTS);

if (strcmp(r->method,"POST") == 0){

     psr = apreq_parser_make(
             r->pool,
             r->connection->bucket_alloc,
             apr_table_get(r->headers_in,"Content-Type"), 

             apreq_parser(apr_table_get(r->headers_in,"Content-Type")),
             0, /* FORCE TO SPOOL FILES */
             "/tmp",
             NULL,
             NULL);
     bb = apr_brigade_create(r->pool,r->connection->bucket_alloc);
     while((s = 
ap_get_brigade(r->input_filters,bb,AP_MODE_READBYTES,APR_BLOCK_READ,HUGE_STRING_LEN)) 
== APR_SUCCESS){
             apreq_parser_run(psr,formd,bb);
             if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) break;
             apr_brigade_cleanup(bb);
         }

     filed = apreq_uploads(formd,r->pool);
}
    /* RUN SCRIPT ENGINE ALLOWING SCRIPTS TO COPY SPOOL FILES TO DESIRED
     * LOCATION IF filed non-empty
     */

Since I set the brigade limit to 0, libapreq will generate a brigade 
with 1 spool bucket for each file param uploaded. Poking through the 
libapreq code and the apr code, I see that on UNIX that writev() is 
called to ultimately write to the spool file. Can I reasonable assume 
that it's okay to expose that spool file name to my script engine to 
allow code to copy that file to another location? If not, should I flush 
the spool file descriptor first, then copy? Any other suggestions?

TIA

BTW - the whole apreq_param_t and apreq_value_t code is pretty sweet.
-- 
Jeffrey Horner       Computer Systems Analyst         School of Medicine
615-322-8606         Department of Biostatistics   Vanderbilt University

Mime
View raw message