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 2004/08/03 07:06:05 UTC

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

joes        2004/08/02 22:06:05

  Modified:    env      mod_apreq.c
               env/t    request.t
  Log:
  Don't steal bad parse data, and don't remove an active filter.
  
  Revision  Changes    Path
  1.58      +22 -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.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- mod_apreq.c	31 Jul 2004 23:56:39 -0000	1.57
  +++ mod_apreq.c	3 Aug 2004 05:06:04 -0000	1.58
  @@ -157,7 +157,7 @@
   
   
   #define APREQ_MODULE_NAME               "APACHE2"
  -#define APREQ_MODULE_MAGIC_NUMBER       20040731
  +#define APREQ_MODULE_MAGIC_NUMBER       20040802
   
   static void apache2_log(const char *file, int line, int level, 
                           apr_status_t status, void *env, const char *fmt,
  @@ -495,6 +495,15 @@
                  upstream apreq filter. */
               ctx = f->next->ctx;
   
  +            switch (ctx->status) {
  +            case APR_SUCCESS:
  +            case APR_INCOMPLETE:
  +                break;
  +            default:
  +                /* bad filter state, don't steal anything */
  +                goto make_new_context;
  +            }
  +
               if (ctx->r != r) {
                   /* r is a new request (subrequest or internal redirect) */
                   apreq_request_t *old_req;
  @@ -526,7 +535,7 @@
       make_new_context:
           apreq_filter_make_context(f);
           if (req != NULL && f == r->input_filters) {
  -            if (req->body != NULL) {
  +            if (req->body_status != APR_EINIT) {
                   req->body = NULL;
                   req->parser = NULL;
                   req->body_status = APR_EINIT;
  @@ -588,9 +597,17 @@
   
           if (ctx->status != APR_INCOMPLETE) {
               if (APR_BRIGADE_EMPTY(ctx->spool)) {
  -                apreq_log(APREQ_DEBUG ctx->status,r,"removing filter (%d)",
  -                          r->input_filters == f);
  -                ap_remove_input_filter(f);
  +                ap_filter_t *next = f->next;
  +
  +                if (cfg->f != f) {
  +                    apreq_log(APREQ_DEBUG ctx->status, r,
  +                              "removing inactive filter (%d)",
  +                              r->input_filters == f);
  +
  +                    ap_remove_input_filter(f);
  +                }
  +                if (APR_BRIGADE_EMPTY(bb))
  +                    return ap_get_brigade(next, bb, mode, block, readbytes);
               }
               return APR_SUCCESS;
           }
  
  
  
  1.12      +14 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- request.t	11 Jul 2004 02:08:47 -0000	1.11
  +++ request.t	3 Aug 2004 05:06:04 -0000	1.12
  @@ -5,7 +5,7 @@
   use Apache::TestUtil;
   use Apache::TestRequest qw(GET_BODY UPLOAD_BODY POST_BODY GET_RC);
   
  -my $num_tests = 14;
  +my $num_tests = 16;
   $num_tests *= 2 if Apache::Test::have_ssl();
   plan tests => $num_tests, have_lwp;
   my $scheme = "http";
  @@ -57,6 +57,19 @@
   \tmore => $filler
   EOT
   }
  +
  +
  +# internal redirect to plain text files (which are non-apreq requests)
  +
  +my $index_html = do {local (@ARGV,$/) = "t/htdocs/index.html"; <> };
  +link "t/htdocs/index.html", "t/htdocs/index.txt";
  +ok t_cmp(GET_BODY("/apreq_redirect_test?test=redirect_index_txt_GET&location=/index.txt"), $index_html, 
  +        "redirect /index.txt (GET)");
  +
  +ok t_cmp(POST_BODY("/apreq_redirect_test?test=redirect_index_txt_POST",
  +        content => "quux=$filler;location=/index.txt;foo=$filler"), $index_html, 
  +        "redirect /index.txt (POST)");
  +
   
   # output filter tests