httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/src apreq.c
Date Tue, 15 Jun 2004 07:55:16 GMT
joes        2004/06/15 00:55:15

  Modified:    .        CHANGES
               env      mod_apreq.c
               env/c-modules/apreq_request_test mod_apreq_request_test.c
               env/t    request.t
               src      apreq.c
  Log:
  Add MaxBody, MaxBrigade, and TempDir configuration directives to mod_apreq
  
  Revision  Changes    Path
  1.40      +3 -0      httpd-apreq-2/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/CHANGES,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- CHANGES	15 Jun 2004 04:18:27 -0000	1.39
  +++ CHANGES	15 Jun 2004 07:55:15 -0000	1.40
  @@ -3,6 +3,9 @@
   
   @section v2_04_dev Changes with libapreq2-2.04-dev
   
  +- C API [joes]
  +  Add MaxBody, MaxBrigade, and TempDir per-dir directives to mod_apreq 
  +  filter.
   
   - C API [joes]
     Replace free/tempnam dependency in apreq_file_mktemp() with
  
  
  
  1.43      +109 -7    httpd-apreq-2/env/mod_apreq.c
  
  Index: mod_apreq.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/mod_apreq.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- mod_apreq.c	14 Jun 2004 02:45:16 -0000	1.42
  +++ mod_apreq.c	15 Jun 2004 07:55:15 -0000	1.43
  @@ -30,6 +30,33 @@
   
   #define dR  request_rec *r = (request_rec *)env
   
  +struct dir_config {
  +    const char         *temp_dir;
  +    apr_off_t           max_body;
  +    apr_ssize_t         max_brigade;
  +};
  +
  +
  +static void *apreq_create_dir_config(apr_pool_t *p, char *d)
  +{
  +    /* dir == OR_ALL */
  +    struct dir_config *dc = apr_palloc(p, sizeof *dc);
  +    dc->temp_dir = NULL;
  +    dc->max_body = -1;
  +    dc->max_brigade = APREQ_MAX_BRIGADE_LEN;
  +    return dc;
  +}
  +
  +static void *apreq_merge_dir_config(apr_pool_t *p, void *a_, void *b_)
  +{
  +    struct dir_config *a = a_, *b = b_, *c = apr_palloc(p, sizeof *c);
  +    c->temp_dir    = (b->temp_dir != NULL)    ? b->temp_dir    : a->temp_dir;
  +    c->max_body    = (b->max_body >= 0)       ? b->max_body    : a->max_body;
  +    c->max_brigade = (b->max_brigade >= 0)    ? b->max_brigade : a->max_brigade;
  +    return c;
  +}
  +
  +
   /** The warehouse. */
   struct env_config {
       apreq_jar_t        *jar;
  @@ -69,7 +96,7 @@
    * Normally the installation process triggered by '% make install'
    * will make the necessary changes to httpd.conf for you.
    * 
  - * XXX describe normal operation, effects of apreq_config_t settings, etc. 
  + * XXX describe normal operation, effects of apenv_config_t settings, etc. 
    *
    * @defgroup mod_apreq Apache-2 Filter Module
    * @ingroup MODULES
  @@ -79,7 +106,7 @@
   
   
   #define APREQ_MODULE_NAME "APACHE2"
  -#define APREQ_MODULE_MAGIC_NUMBER 20040613
  +#define APREQ_MODULE_MAGIC_NUMBER 20040615
   
   
   static void apache2_log(const char *file, int line, int level, 
  @@ -130,10 +157,20 @@
       struct env_config *cfg = 
           ap_get_module_config(r->request_config, &apreq_module);
       if (cfg == NULL) {
  +        struct dir_config *d = ap_get_module_config(r->per_dir_config, 
  +                                                    &apreq_module);
           cfg = apr_pcalloc(r->pool, sizeof *cfg);
           ap_set_module_config(r->request_config, &apreq_module, cfg);
  -        cfg->max_body = -1;
  -        cfg->max_brigade = APREQ_MAX_BRIGADE_LEN;
  +
  +        if (d) {
  +            cfg->temp_dir    = d->temp_dir;
  +            cfg->max_body    = d->max_body;
  +            cfg->max_brigade = d->max_brigade;
  +        } 
  +        else {
  +            cfg->max_body    = -1;
  +            cfg->max_brigade = APREQ_MAX_BRIGADE_LEN;
  +        }
       }
       return cfg;
   }
  @@ -316,6 +353,7 @@
       struct filter_ctx *ctx;
       struct env_config *cfg = get_cfg(r);
   
  +
       /* We must be inside config.c:ap_invoke_handler -> 
        * ap_invoke_filter_init (r->input_filters), and
        * we have to deal with the possibility that apreq may have
  @@ -520,15 +558,79 @@
                                AP_FTYPE_CONTENT_SET);
   }
   
  +
  +/* Configuration directives */
  +
  +
  +static const char *apreq_set_temp_dir(cmd_parms *cmd, void *data,
  +                                      const char *arg)
  +{
  +    struct dir_config *conf = data;
  +    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
  +
  +    if (err != NULL)
  +        return err;
  +
  +    conf->temp_dir = arg;
  +    return NULL;
  +}
  +
  +static const char *apreq_set_max_body(cmd_parms *cmd, void *data,
  +                                      const char *arg)
  +{
  +    struct dir_config *conf = data;
  +    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
  +
  +    if (err != NULL)
  +        return err;
  +
  +    conf->max_body = apreq_atoi64f(arg);
  +
  +    if (conf->max_body < 0)
  +        return "ApReqMaxBody requires a non-negative integer.";
  +
  +    return NULL;
  +}
  +
  +static const char *apreq_set_max_brigade(cmd_parms *cmd, void *data,
  +                                          const char *arg)
  +{
  +    struct dir_config *conf = data;
  +    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
  +
  +    if (err != NULL)
  +        return err;
  +
  +
  +    conf->max_brigade = apreq_atoi64f(arg);
  +
  +    if (conf->max_brigade < 0)
  +        return "ApReqMaxBody requires a non-negative integer.";
  +
  +    return NULL;
  +}
  +
  +static const command_rec apreq_cmds[] =
  +{
  +    AP_INIT_TAKE1("APREQ_TempDir", apreq_set_temp_dir, NULL, OR_ALL,
  +                  "Default location of temporary directory"),
  +    AP_INIT_TAKE1("APREQ_MaxBody", apreq_set_max_body, NULL, OR_ALL,
  +                  "Maximum amount of data that can be fed into libapreq."),
  +    AP_INIT_TAKE1("APREQ_MaxBrigade", apreq_set_max_brigade, NULL, OR_ALL,
  +                  "Maximum in-memory bytes a stored brigade may use."),
  +    {NULL}
  +};
  +
  +
   /** @} */
   
   module AP_MODULE_DECLARE_DATA apreq_module =
   {
   	STANDARD20_MODULE_STUFF,
  +	apreq_create_dir_config,
  +	apreq_merge_dir_config,
   	NULL,
   	NULL,
  -	NULL,
  -	NULL,
  -	NULL,
  +	apreq_cmds,
   	register_hooks,			/* callback for registering hooks */
   };
  
  
  
  1.7       +1 -0      httpd-apreq-2/env/c-modules/apreq_request_test/mod_apreq_request_test.c
  
  Index: mod_apreq_request_test.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/c-modules/apreq_request_test/mod_apreq_request_test.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mod_apreq_request_test.c	16 Apr 2004 03:21:03 -0000	1.6
  +++ mod_apreq_request_test.c	15 Jun 2004 07:55:15 -0000	1.7
  @@ -17,6 +17,7 @@
   #if CONFIG_FOR_HTTPD_TEST
   
   <Location /apreq_request_test>
  +   APREQ_MaxBody 500K
      SetHandler apreq_request_test
   </Location>
   
  
  
  
  1.10      +1 -1      httpd-apreq-2/env/t/request.t
  
  Index: request.t
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/t/request.t,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- request.t	13 Jun 2004 17:37:40 -0000	1.9
  +++ request.t	15 Jun 2004 07:55:15 -0000	1.10
  @@ -25,7 +25,7 @@
   
   ok t_cmp(403, GET_RC("/apreq_access_test"), "access denied");
   
  -my $filler = "0123456789";# x 6400; # < 64K
  +my $filler = "0123456789" x 6400; # < 64K
   my $body = POST_BODY("/apreq_access_test?foo=1;", 
                        content => "bar=2&quux=$filler;test=6&more=$filler");
   ok t_cmp(<<EOT, $body, "prefetch credentials");
  
  
  
  1.37      +2 -2      httpd-apreq-2/src/apreq.c
  
  Index: apreq.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- apreq.c	15 Jun 2004 04:32:08 -0000	1.36
  +++ apreq.c	15 Jun 2004 07:55:15 -0000	1.37
  @@ -680,7 +680,7 @@
                                                 apr_pool_t *pool,
                                                 const char *path)
   {
  -    apr_status_t rc = APR_SUCCESS;
  +    apr_status_t rc;
       char *tmpl;
   
       if (path == NULL) {
  @@ -699,7 +699,7 @@
                              | APR_EXCL | APR_DELONCLOSE | APR_BINARY, pool);
   }
   
  -/* circumvents linker issue (perl's CCFLAGS != apr's CCFLAGS) on linux */
  +
   APREQ_DECLARE(apr_file_t *)apreq_brigade_spoolfile(apr_bucket_brigade *bb)
   {
       apr_bucket *last = APR_BRIGADE_LAST(bb);
  
  
  

Mime
View raw message