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_params.c apreq_parsers.c
Date Tue, 13 Apr 2004 21:46:38 GMT
joes        2004/04/13 14:46:38

  Modified:    env/c-modules/apreq_request_test mod_apreq_request_test.c
               glue/perl/xsbuilder/Apache/Request Apache__Request.h
               src      apreq_params.c apreq_parsers.c
  Log:
  Mark missing-CRLF issue in mfd code.  Simplify semantics for apreq_param & apreq_upload
by reading POST data until desired key is found. Also simplify one of the env test modules
by checking for EOS in last bucket instead of checking all buckets.
  
  Revision  Changes    Path
  1.5       +8 -19     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mod_apreq_request_test.c	28 Feb 2004 07:48:14 -0000	1.4
  +++ mod_apreq_request_test.c	13 Apr 2004 21:46:38 -0000	1.5
  @@ -42,36 +42,25 @@
       apr_bucket_brigade *bb;
       apreq_request_t *req;
       apr_status_t s;
  -    int saw_eos = 0;
   
       if (strcmp(r->handler, "apreq_request_test") != 0)
           return DECLINED;
   
       apreq_log(APREQ_DEBUG 0, r, "initializing request");
       req = apreq_request(r, NULL);
  -
  -
       bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
  -    
  -    do {
  -        apr_bucket *e;
  -        apreq_log(APREQ_DEBUG 0, r, "pulling content thru input filters");
  -        s = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
  -                           APR_BLOCK_READ, HUGE_STRING_LEN);
   
  -        for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb);
  -             e = APR_BUCKET_NEXT(e))
  -        {
  -            if (APR_BUCKET_IS_EOS(e)) {
  -                saw_eos = 1;
  -                break;
  -            }
  -        }
  +    apreq_log(APREQ_DEBUG 0, r, "start parsing body");    
  +    while ((s =ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
  +                              APR_BLOCK_READ, HUGE_STRING_LEN)) == APR_SUCCESS)
  +    {
  +        if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))
  +            break;
   
           apr_brigade_cleanup(bb);
   
  -    } while (!saw_eos);
  -    apreq_log(APREQ_DEBUG 0, r, "no more content");
  +    }
  +    apreq_log(APREQ_DEBUG s, r, "finished parsing body");
   
       ap_set_content_type(r, "text/plain");
       ap_rputs("ARGS:\n",r);
  
  
  
  1.23      +6 -5      httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
  
  Index: Apache__Request.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Apache__Request.h	13 Apr 2004 00:41:55 -0000	1.22
  +++ Apache__Request.h	13 Apr 2004 21:46:38 -0000	1.23
  @@ -96,14 +96,15 @@
                                         const char *val)
   {
       struct apreq_xs_do_arg *d = (struct apreq_xs_do_arg *)data;
  -    apreq_param_t *param = apreq_value_to_param(apreq_strtoval(val));
       dTHXa(d->perl);
       dSP;
  -    if (param->bb == NULL)      /* not an upload, so skip it */
  -        return 1;
   
  -    if (key)
  -        XPUSHs(sv_2mortal(newSVpv(key,0)));
  +    if (key) {
  +        if (val && apreq_value_to_param(apreq_strtoval(val))->bb)
  +            XPUSHs(sv_2mortal(newSVpv(key,0)));
  +        else    /* not an upload, so skip it */
  +            return 1;
  +    }
       else
           XPUSHs(&PL_sv_undef);
   
  
  
  
  1.39      +19 -11    httpd-apreq-2/src/apreq_params.c
  
  Index: apreq_params.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- apreq_params.c	24 Mar 2004 08:22:48 -0000	1.38
  +++ apreq_params.c	13 Apr 2004 21:46:38 -0000	1.39
  @@ -103,16 +103,16 @@
   {
       const char *val = apr_table_get(req->args, name);
   
  -    if (val == NULL && req->body)
  +    while (val == NULL) {
  +        apr_status_t s = apreq_env_read(req->env, APR_BLOCK_READ,APREQ_READ_AHEAD);
  +        if (req->body == NULL)
  +            return NULL;
           val = apr_table_get(req->body, name);
  -
  -    if (val == NULL) {
  -        apreq_env_read(req->env, APR_BLOCK_READ, APREQ_READ_AHEAD);
  -        if (req->body)
  -            val = apr_table_get(req->body, name);
  +        if (s != APR_INCOMPLETE && val == NULL)
  +            return NULL;
       }
   
  -    return val ? apreq_value_to_param(apreq_strtoval(val)) : NULL;
  +    return apreq_value_to_param(apreq_strtoval(val));
   }
   
   
  @@ -285,13 +285,21 @@
           return 0; /* keep searching */
   }
   
  +
   APREQ_DECLARE(apreq_param_t *) apreq_upload(const apreq_request_t *req,
                                               const char *key)
   {
       apreq_param_t *param = NULL;
  -    apreq_env_read(req->env, APR_BLOCK_READ, APREQ_READ_AHEAD);
  -    if (req->body == NULL)
  -        return NULL;
  -    apr_table_do(upload_get, &param, req->body, key, NULL);
  +    do {
  +        apr_status_t s = apreq_env_read(req->env, APR_BLOCK_READ,
  +                                        APREQ_READ_AHEAD);
  +        if (req->body == NULL)
  +            return NULL;
  +        apr_table_do(upload_get, &param, req->body, key, NULL);
  +
  +        if (s != APR_INCOMPLETE)
  +            break;
  +    } while (param == NULL);
  +
       return param;
   }
  
  
  
  1.42      +9 -0      httpd-apreq-2/src/apreq_parsers.c
  
  Index: apreq_parsers.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_parsers.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- apreq_parsers.c	24 Mar 2004 21:51:12 -0000	1.41
  +++ apreq_parsers.c	13 Apr 2004 21:46:38 -0000	1.42
  @@ -833,6 +833,15 @@
                   apr_table_addn(t, param->v.name, param->v.data);
                   ctx->status = MFD_UPLOAD;
               }
  +            /* XXX must handle special case of missing CRLF (mainly
  +               coming from empty file uploads). See RFC2065 S5.1.1:
  +
  +                 body-part = MIME-part-header [CRLF *OCTET]
  +
  +               So the CRLF we already matched may have been part of
  +               the boundary string! Both Konqueror (v??) and Mozilla-0.97
  +               are known to emit such blocks.
  +            */
           }
           goto mfd_parse_brigade;
   
  
  
  

Mime
View raw message