You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/11/07 06:54:57 UTC

cvs commit: httpd-apreq-2/env/t request.t

joes        2003/11/06 21:54:57

  Modified:    env      mod_apreq.c
               env/t    request.t
  Added:       env/c-modules/apreq_output_filter_test .cvsignore
                        mod_apreq_output_filter_test.c
  Log:
  Do not allow parser errors to creep into apreq_filter() return values.  New output filter tests added to confirm the change.
  
  Revision  Changes    Path
  1.37      +7 -5      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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- mod_apreq.c	31 Oct 2003 20:50:18 -0000	1.36
  +++ mod_apreq.c	7 Nov 2003 05:54:57 -0000	1.37
  @@ -114,7 +114,7 @@
   
   
   #define APREQ_MODULE_NAME "APACHE2"
  -#define APREQ_MODULE_MAGIC_NUMBER 20031031
  +#define APREQ_MODULE_MAGIC_NUMBER 20031107
   
   
   static void apache2_log(const char *file, int line, int level, 
  @@ -401,7 +401,7 @@
                             r->input_filters == f);
                   ap_remove_input_filter(f);
               }
  -            return ctx->status;
  +            return APR_SUCCESS;
           }
   
           if (req == NULL)
  @@ -441,10 +441,12 @@
           }
       }
       else
  -        return ctx->status;
  +        return APR_SUCCESS;
  +
  +    if (ctx->status == APR_INCOMPLETE)
  +        ctx->status = apreq_parse_request(req, ctx->bb);
   
  -    ctx->status = apreq_parse_request(req, ctx->bb);
  -    return (ctx->status == APR_INCOMPLETE) ? APR_SUCCESS : ctx->status;
  +    return APR_SUCCESS;
   }
   
   static APREQ_ENV_MODULE(apache2, APREQ_MODULE_NAME,
  
  
  
  1.1                  httpd-apreq-2/env/c-modules/apreq_output_filter_test/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  .libs
  Makefile
  mod_apreq_output_filter_test.la
  mod_apreq_output_filter_test.slo
  
  
  
  1.1                  httpd-apreq-2/env/c-modules/apreq_output_filter_test/mod_apreq_output_filter_test.c
  
  Index: mod_apreq_output_filter_test.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #if CONFIG_FOR_HTTPD_TEST
  
  <Location />
     AddOutputFilter APREQ_OUTPUT_FILTER html
  </Location>
  
  #endif
  
  #include "apache_httpd_test.h"
  #include "apreq_params.h"
  #include "apreq_env.h"
  #include "httpd.h"
  #include "util_filter.h"
  
  static const char filter_name[] =  "APREQ_OUTPUT_FILTER";
  module AP_MODULE_DECLARE_DATA apreq_output_filter_test_module;
  
  static apr_status_t apreq_output_filter_test_init(ap_filter_t *f)
  {
      apreq_request_t *req;
      req = apreq_request(f->r, NULL);
      return APR_SUCCESS;
  }
  
  struct ctx_t {
      request_rec *r;
      apr_bucket_brigade *bb;
  };
  
  static int dump_table(void *data, const char *key, const char *value)
  {
      struct ctx_t *ctx = (struct ctx_t *)data;
      apreq_log(APREQ_DEBUG 0, ctx->r, "%s => %s", key, value);
      apr_brigade_printf(ctx->bb,NULL,NULL,"\t%s => %s\n", key, value);
      return 1;
  }
  
  static apr_status_t apreq_output_filter_test(ap_filter_t *f, apr_bucket_brigade *bb)
  {
      request_rec *r = f->r;
      apreq_request_t *req;
      apr_bucket_brigade *eos;
      struct ctx_t ctx = {r, bb};
  
      if (!APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb)))
          return ap_pass_brigade(f->next,bb);
  
      eos = apr_brigade_split(bb, APR_BRIGADE_LAST(bb));
  
      req = apreq_request(r, NULL);
      apreq_log(APREQ_DEBUG 0, r, "appending parsed data");
      apr_brigade_puts(bb, NULL, NULL, "\n--APREQ OUTPUT FILTER--\nARGS:\n");
      apr_table_do(dump_table, &ctx, req->args, NULL);
  
      if (req->body) {
          apr_brigade_puts(bb,NULL,NULL,"BODY:\n");
          apr_table_do(dump_table,&ctx,req->body,NULL);
      }
      APR_BRIGADE_CONCAT(bb,eos);
      return ap_pass_brigade(f->next,bb);
  }
  
  static void register_hooks (apr_pool_t *p)
  {
      ap_register_output_filter(filter_name, apreq_output_filter_test, 
                                apreq_output_filter_test_init,
                                AP_FTYPE_CONTENT_SET);
  }
  
  module AP_MODULE_DECLARE_DATA apreq_output_filter_test_module =
  {
  	STANDARD20_MODULE_STUFF,
  	NULL,
  	NULL,
  	NULL,
  	NULL,
  	NULL,
  	register_hooks,			/* callback for registering hooks */
  };
  
  
  
  1.7       +26 -2     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- request.t	1 Oct 2003 20:00:36 -0000	1.6
  +++ request.t	7 Nov 2003 05:54:57 -0000	1.7
  @@ -5,7 +5,7 @@
   use Apache::TestUtil;
   use Apache::TestRequest qw(GET_BODY UPLOAD_BODY POST_BODY GET_RC);
   
  -plan tests => 11;
  +plan tests => 14;
   
   foreach my $location ('/apreq_request_test', '/apreq_access_test') {
   
  @@ -19,7 +19,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");
  @@ -51,3 +51,27 @@
   \tmore => $filler
   EOT
   }
  +
  +# output filter tests
  +
  +sub filter_content ($) {
  +   my $body = shift;      
  +   $body =~ s/^.*--APREQ OUTPUT FILTER--\s+//s;
  +   return $body;
  +}
  +
  +ok t_cmp(200, GET_RC("/index.html"), "/index.html");
  +ok t_cmp("ARGS:\n\ttest => 13\n", filter_content
  +         GET_BODY("/index.html?test=13"), "output filter GET");
  +
  +ok t_cmp(<<EOT,
  +ARGS:
  +\ttest => 14
  +BODY:
  +\tpost data => foo
  +\tmore => $filler
  +\ttest => output filter POST
  +EOT
  +     filter_content POST_BODY("/index.html?test=14", content => 
  +     "post+data=foo;more=$filler;test=output+filter+POST"), 
  +     "output filter POST");