httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r155866 - in httpd/apreq/branches/multi-env-unstable: glue/perl/lib/Apache/ glue/perl/t/apreq/ glue/perl/t/response/TestApReq/ glue/perl/xsbuilder/APR/Request/Param/ include/ library/
Date Wed, 02 Mar 2005 03:40:08 GMT
Author: joes
Date: Tue Mar  1 19:40:06 2005
New Revision: 155866

URL: http://svn.apache.org/viewcvs?view=rev&rev=155866
Log:
Working on Apache::Upload API... with this patch, the failure list
should be:

Failed Test       Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/apreq/request.t               18   10  55.56%  4-5 10-15 17-18

Added:
    httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Upload.pm
Modified:
    httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/request.t
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/request.pm
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.pm
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
    httpd/apreq/branches/multi-env-unstable/include/apreq_util.h
    httpd/apreq/branches/multi-env-unstable/library/util.c

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm Tue Mar  1 19:40:06
2005
@@ -1,12 +1,7 @@
 package Apache::Request;
 use APR::Request::Param;
-use APR::Request::Apache2;
+use APR::Request::Apache2 qw/args/;
 use Apache::RequestRec;
 push our @ISA, qw/Apache::RequestRec APR::Request::Apache2/;
-
-
-package Apache::Upload;
-use APR::Request::Param;
-push our @ISA, qw/APR::Request::Param/;
 
 1;

Added: httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Upload.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Upload.pm?view=auto&rev=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Upload.pm (added)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Upload.pm Tue Mar  1 19:40:06
2005
@@ -0,0 +1,18 @@
+package Apache::Upload;
+use Apache::Request;
+push our @ISA, qw/APR::Request::Param/;
+no strict 'refs';
+for (qw/slurp type size link tempname/) {
+    *{$_} = *{"APR::Request::Param::upload_$_"}{CODE};
+}
+sub Apache::Request::upload {
+    my $req = shift;
+    my $body = $req->body;
+    $body->param_class(__PACKAGE__);
+    my @uploads = grep $_->upload,
+                  @_ ? $body->get(@_) : values %$body;
+    wantarray ? @uploads : $uploads[0];
+}
+
+
+1;

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/request.t
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/request.t?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/request.t (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/apreq/request.t Tue Mar  1 19:40:06
2005
@@ -6,7 +6,7 @@
 use Apache::TestUtil;
 use Apache::TestRequest qw(GET_BODY UPLOAD_BODY);
 
-plan tests => 18, under_construction;#have_lwp
+plan tests => 18, have_lwp;
 
 my $location = "/TestApReq__request";
 #print GET_BODY $location;
@@ -20,6 +20,7 @@
              "basic param");
 }
 
+
 for my $test (qw/slurp bb tempname link fh io bad;query=string%%/) {
     # upload a string as a file
     my $value = ('DataUpload' x 10 . "\n") x 1_000;
@@ -33,11 +34,13 @@
     ok t_cmp($i, length($value), "basic upload length");    
 }
 
+
 {
     my $value = 'DataUpload' x 100;
     my $result = UPLOAD_BODY("$location?test=type", content => $value); 
     ok t_cmp($result, "text/plain", "type");
 }
+
 {
     my $value = 'DataUpload' x 100;
     my $result = UPLOAD_BODY("$location?test=hook", content => $value); 

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/request.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/request.pm?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/request.pm (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/response/TestApReq/request.pm Tue
Mar  1 19:40:06 2005
@@ -28,9 +28,10 @@
     my $r = shift;
     my $temp_dir =
         File::Spec->catfile(Apache::ServerUtil::server_root, 'logs'); 
-    my $req = Apache::Request->new($r, POST_MAX => 1_000_000,
-                                       TEMP_DIR => $temp_dir);
-
+    my $req = Apache::Request->new($r);#, POST_MAX => 1_000_000,
+                                       #TEMP_DIR => $temp_dir);
+    $req->temp_dir($temp_dir);
+    $req->read_limit(1_000_000);
     $req->content_type('text/plain');
 
     my $test  = $req->args('test');
@@ -38,17 +39,11 @@
 
     if ($test eq 'param') {
         my $table = $req->args();
-        $table->add("new_arg" => "new");
-        die "Can't find new_arg" unless $table->{new_arg} eq "new";
-        $table->{new_arg} = 1;
-        die "Can't find newer arg" unless $table->get("new_arg") == 1;
-        delete $table->{new_arg};
-        die "New arg still exists after deletion" if exists $table->{new_arg};
         my $value = $req->param('value');
         $req->print($value);
     }
     elsif ($test eq 'slurp') {
-        my ($upload) = values %{$req->upload};
+        my ($upload) = $req->upload;#values %{$req->upload};
         $upload->slurp(my $data);
         if ($upload->size != length $data) {
             $req->print("Size mismatch: size() reports ", $upload->size,
@@ -146,8 +141,8 @@
             my $upload = $@->upload('HTTPUPLOAD'); # no exception this time!
             die "args test failed" unless $args eq $test;
             $args = $@->args;
-            $args->add("foo" => "bar1");
-            $args->add("foo" => "bar2");
+#            $args->add("foo" => "bar1");
+#            $args->add("foo" => "bar2");
             my $test_string = "";
 
             # MAGIC ITERATOR TESTS

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/APR__Request__Param.h
Tue Mar  1 19:40:06 2005
@@ -70,187 +70,6 @@
 /* Upload-related stuff */
 #if 0
 
-static XS(apreq_xs_upload_link)
-{
-    dXSARGS;
-    MAGIC *mg;
-    void *env;
-    const char *name, *fname;
-    apr_bucket_brigade *bb;
-    apr_file_t *f;
-    apr_status_t s = APR_SUCCESS;
-    SV *sv, *obj;
-
-    if (items != 2 || !SvROK(ST(0)))
-        Perl_croak(aTHX_ "Usage: $upload->link($filename)");
-
-    if (SvTAINTED(ST(1)))
-        Perl_croak(aTHX_ "$upload->link($filename): Cannot link to tainted $filename:
%s", 
-                   SvPV_nolen(ST(1)));
-
-    sv = ST(0);
-    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
-
-    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
-        Perl_croak(aTHX_ "$upload->link($name): panic: can't find env.");
-
-    env = mg->mg_ptr;
-    bb = ((apreq_param_t *)SvIVX(obj))->bb;
-    name = SvPV_nolen(ST(1));
-
-    f = apreq_brigade_spoolfile(bb);
-    if (f == NULL) {
-        apr_off_t len;
-
-        s = apr_file_open(&f, name, APR_CREATE | APR_EXCL | APR_WRITE |
-                          APR_READ | APR_BINARY,
-                          APR_OS_DEFAULT,
-                          apreq_env_pool(env));
-        if (s == APR_SUCCESS) {
-            s = apreq_brigade_fwrite(f, &len, bb);
-            if (s == APR_SUCCESS)
-                XSRETURN_YES;
-        }
-        goto link_error;
-    }
-    s = apr_file_name_get(&fname, f);
-    if (s != APR_SUCCESS)
-        goto link_error;
-
-    if (PerlLIO_link(fname, name) >= 0)
-        XSRETURN_YES;
-    else {
-        s = apr_file_copy(fname, name,
-                          APR_OS_DEFAULT, 
-                          apreq_env_pool(env));
-        if (s == APR_SUCCESS)
-            XSRETURN_YES;
-    }
-
- link_error:
-    APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::link", 
-                         "Apache::Upload::Error");
-    XSRETURN_UNDEF;
-}
-
-
-static XS(apreq_xs_upload_slurp)
-{
-    dXSARGS;
-    MAGIC *mg;
-    void *env;
-    char *data;
-    apr_off_t len_off;
-    apr_size_t len_size;
-    apr_bucket_brigade *bb;
-    SV *sv, *obj;
-    apr_status_t s;
-
-    if (items != 2 || !SvROK(ST(0)))
-        Perl_croak(aTHX_ "Usage: $upload->slurp($data)");
-
-    sv = ST(0);
-    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
-
-    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
-        Perl_croak(aTHX_ "$upload->slurp($data): can't find env");
-
-    env = mg->mg_ptr;
-    bb = ((apreq_param_t *)SvIVX(obj))->bb;
-
-    s = apr_brigade_length(bb, 0, &len_off);
-    if (s != APR_SUCCESS) {
-        APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::slurp", 
-                             "Apache::Upload::Error");
-        XSRETURN_UNDEF;
-    }
-
-    len_size = len_off; /* max_body setting will be low enough to prevent
-                         * overflow, but even if it wasn't the code below will
-                         * at worst truncate the slurp data (not segfault).
-                         */
-                         
-    SvUPGRADE(ST(1), SVt_PV);
-    data = SvGROW(ST(1), len_size + 1);
-    data[len_size] = 0;
-    SvCUR_set(ST(1), len_size);
-    SvPOK_only(ST(1));
-    s = apr_brigade_flatten(bb, data, &len_size);
-    if (s != APR_SUCCESS) {
-        APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::slurp", 
-                             "Apache::Upload::Error");
-        XSRETURN_UNDEF;
-    }
-    if (SvTAINTED(obj))
-        SvTAINTED_on(ST(1));
-    SvSETMAGIC(ST(1));
-    XSRETURN_IV(len_size);
-}
-
-static XS(apreq_xs_upload_size)
-{
-    dXSARGS;
-    MAGIC *mg;
-    void *env;
-    apr_bucket_brigade *bb;
-    apr_status_t s;
-    apr_off_t len;
-    SV *sv, *obj;
-
-    if (items != 1 || !SvROK(ST(0)))
-        Perl_croak(aTHX_ "Usage: $upload->size()");
-
-    sv = ST(0);
-    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
-
-    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
-        Perl_croak(aTHX_ "$upload->size(): can't find env");
-
-    env = mg->mg_ptr;
-    bb = ((apreq_param_t *)SvIVX(obj))->bb;
-
-    s = apr_brigade_length(bb, 1, &len);
-
-    if (s != APR_SUCCESS) {
-        APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::size", 
-                             "Apache::Upload::Error");
-        XSRETURN_UNDEF;
-    }
-
-    XSRETURN_IV((IV)len);
-}
-
-static XS(apreq_xs_upload_type)
-{
-    dXSARGS;
-    apreq_param_t *upload;
-    const char *ct, *sc;
-    STRLEN len;
-    SV *sv, *obj;
-
-    if (items != 1 || !SvROK(ST(0)))
-        Perl_croak(aTHX_ "Usage: $upload->type()");
-
-    sv = ST(0);
-    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
-
-    upload = (apreq_param_t *)SvIVX(obj);
-    ct = apr_table_get(upload->info, "Content-Type");
-    if (ct == NULL)
-        Perl_croak(aTHX_ "$upload->type: can't find Content-Type header");
-    
-    if ((sc = strchr(ct, ';')))
-        len = sc - ct;
-    else
-        len = strlen(ct);
-
-    sv = newSVpvn(ct, len);
-    if (SvTAINTED(obj))
-        SvTAINTED_on(sv);
-    ST(0) = sv_2mortal(sv);
-    XSRETURN(1);
-}
-
 APR_INLINE
 static SV *apreq_xs_find_bb_obj(pTHX_ SV *in)
 {
@@ -461,62 +280,4 @@
     PUTBACK;
 }
 
-
-static XS(apreq_xs_upload_tempname)
-{
-    dXSARGS;
-    MAGIC *mg;
-    void *env;
-    apr_bucket_brigade *bb;
-    apr_status_t s;
-    apr_file_t *file;
-    const char *path;
-    SV *sv, *obj;
-
-    if (items != 1 || !SvROK(ST(0)))
-        Perl_croak(aTHX_ "Usage: $upload->tempname()");
-
-    sv = ST(0);
-    obj = apreq_xs_find_obj(aTHX_ sv, "upload");
-
-    if (!(mg = mg_find(obj, PERL_MAGIC_ext)))
-        Perl_croak(aTHX_ "$upload->tempname(): can't find env");
-
-    env = mg->mg_ptr;
-    bb = ((apreq_param_t *)SvIVX(obj))->bb;
-    file = apreq_brigade_spoolfile(bb);
-
-    if (file == NULL) {
-        apr_bucket *last;
-        apr_off_t len;
-        const char *tmpdir = apreq_env_temp_dir(env, NULL);
-
-        s = apreq_file_mktemp(&file, apreq_env_pool(env), tmpdir);
-
-        if (s != APR_SUCCESS)
-            goto tempname_error;
-
-        s = apreq_brigade_fwrite(file, &len, bb);
-
-        if (s != APR_SUCCESS)
-            goto tempname_error;
-
-        last = apr_bucket_file_create(file, len, 0, bb->p, bb->bucket_alloc);
-        APR_BRIGADE_INSERT_TAIL(bb, last);
-    }
-
-    s = apr_file_name_get(&path, file);
-    if (s != APR_SUCCESS)
-        goto tempname_error;
-
-    sv = newSVpvn(path, strlen(path));
-    ST(0) = sv_2mortal(sv);
-    XSRETURN(1);
-
- tempname_error:
-    APREQ_XS_THROW_ERROR(upload, s, "Apache::Upload::tempname", 
-                         "Apache::Upload::Error");
-    XSRETURN_UNDEF;
-
-}
 #endif

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.pm
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.pm?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.pm
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.pm
Tue Mar  1 19:40:06 2005
@@ -1 +1,2 @@
 use APR::Request;
+use APR::Table;

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
Tue Mar  1 19:40:06 2005
@@ -470,3 +470,161 @@
   OUTPUT:
     RETVAL
    
+
+
+MODULE = APR::Request::Param PACKAGE = APR::Request::Param
+
+SV *
+upload_link(param, path)
+    APR::Request::Param param
+    const char *path
+  PREINIT:
+    apr_file_t *f;
+    const char *fname;
+    apr_status_t s;
+
+  CODE:
+    if (param->upload == NULL)
+        Perl_croak(aTHX_ "$param->upload_link($file): param has no upload brigade");
+    f = apreq_brigade_spoolfile(param->upload);
+    if (f == NULL) {
+        apr_off_t len;
+        s = apr_file_open(&f, path, APR_CREATE | APR_EXCL | APR_WRITE |
+                          APR_READ | APR_BINARY,
+                          APR_OS_DEFAULT,
+                          param->upload->p);
+        if (s == APR_SUCCESS) {
+            s = apreq_brigade_fwrite(f, &len, param->upload);
+            if (s == APR_SUCCESS)
+                XSRETURN_YES;
+        }
+    }
+    else {
+        s = apr_file_name_get(&fname, f);
+        if (s != APR_SUCCESS)
+            Perl_croak(aTHX_ "$param->upload_link($file): can't get spoolfile name");
+        if (PerlLIO_link(fname, path) >= 0)
+            XSRETURN_YES;
+        else {
+            s = apr_file_copy(fname, path, APR_OS_DEFAULT, param->upload->p);
+            if (s == APR_SUCCESS)
+                XSRETURN_YES;
+        }
+    }
+    RETVAL = &PL_sv_undef;
+
+  OUTPUT:
+    RETVAL
+
+apr_size_t
+upload_slurp(param, buffer)
+    APR::Request::Param param
+    SV *buffer
+  PREINIT:
+    apr_off_t len;
+    apr_status_t s;
+    char *data;
+
+  CODE:
+    if (param->upload == NULL)
+        Perl_croak(aTHX_ "$param->upload_slurp($data): param has no upload brigade");
+
+    s = apr_brigade_length(param->upload, 0, &len);
+    if (s != APR_SUCCESS)
+        Perl_croak(aTHX_ "$param->upload_slurp($data): can't get upload length");
+
+    RETVAL = len;
+    SvUPGRADE(buffer, SVt_PV);
+    data = SvGROW(buffer, RETVAL + 1);
+    data[RETVAL] = 0;
+    SvCUR_set(buffer, RETVAL);
+    SvPOK_only(buffer);
+    s = apr_brigade_flatten(param->upload, data, &RETVAL);
+    if (s != APR_SUCCESS)
+        Perl_croak(aTHX_ "$param->upload_slurp($data): can't flatten upload");
+
+    if (apreq_param_is_tainted(param))
+        SvTAINTED_on(buffer);
+
+    SvSETMAGIC(buffer);
+
+  OUTPUT:
+    RETVAL
+
+UV
+upload_size(param)
+    APR::Request::Param param
+  PREINIT:
+    apr_off_t len;
+    apr_status_t s;
+
+  CODE:
+    if (param->upload == NULL)
+        Perl_croak(aTHX_ "$param->upload_size(): param has no upload brigade");
+
+    s = apr_brigade_length(param->upload, 0, &len);
+    if (s != APR_SUCCESS)
+        Perl_croak(aTHX_ "$param->upload_size(): can't get upload length");
+
+    RETVAL = len;    
+
+  OUTPUT:
+    RETVAL
+
+SV *
+upload_type(param)
+    APR::Request::Param param
+  PREINIT:
+    const char *ct, *sc;
+    STRLEN len;
+  CODE:
+    if (param->info == NULL)
+        Perl_croak(aTHX_ "$param->upload_type(): param has no info table");
+
+    ct = apr_table_get(param->info, "Content-Type");
+    if (ct == NULL)
+        Perl_croak(aTHX_ "$param->upload_type: can't find Content-Type header");
+    
+    if ((sc = index(ct, ';')))
+        len = sc - ct;
+    else
+        len = strlen(ct);
+
+    RETVAL = newSVpvn(ct, len);    
+    if (apreq_param_is_tainted(param))
+        SvTAINTED_on(RETVAL);
+
+  OUTPUT:
+    RETVAL
+
+
+const char *
+upload_tempname(param, req=apreq_xs_sv2handle(aTHX_ ST(0)))
+    APR::Request::Param param
+    APR::Request req
+
+  PREINIT:
+    apr_file_t *f;
+    apr_status_t s;
+
+  CODE:
+    if (param->upload == NULL)
+        Perl_croak(aTHX_ "$param->upload_tempname($req): param has no upload brigade");
+    f = apreq_brigade_spoolfile(param->upload);
+    if (f == NULL) {
+        const char *path;
+        s = apreq_temp_dir_get(req, &path);
+        if (s != APR_SUCCESS)
+            Perl_croak(aTHX_ "$param->upload_tempname($req): can't get temp_dir");
+        s = apreq_brigade_concat(param->upload->p, path, 0, 
+                                 param->upload, param->upload);
+        if (s != APR_SUCCESS)
+            Perl_croak(aTHX_ "$param->upload_tempname($req): can't make spool bucket");
+        f = apreq_brigade_spoolfile(param->upload);
+    }
+    s = apr_file_name_get(&RETVAL, f);
+    if (s != APR_SUCCESS)
+        Perl_croak(aTHX_ "$param->upload_link($file): can't get spool file name");
+
+  OUTPUT:
+    RETVAL

Modified: httpd/apreq/branches/multi-env-unstable/include/apreq_util.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/include/apreq_util.h?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/include/apreq_util.h (original)
+++ httpd/apreq/branches/multi-env-unstable/include/apreq_util.h Tue Mar  1 19:40:06 2005
@@ -347,6 +347,7 @@
                                                  apr_bucket_brigade *out, 
                                                  apr_bucket_brigade *in);
 
+APREQ_DECLARE(apr_file_t *)apreq_brigade_spoolfile(apr_bucket_brigade *bb);
 
 #ifdef __cplusplus
  }

Modified: httpd/apreq/branches/multi-env-unstable/library/util.c
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/util.c?view=diff&r1=155865&r2=155866
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/util.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/util.c Tue Mar  1 19:40:06 2005
@@ -769,6 +769,16 @@
     apr_bucket_copy_notimpl,
 };
 
+APREQ_DECLARE(apr_file_t *)apreq_brigade_spoolfile(apr_bucket_brigade *bb)
+{
+    apr_bucket *last;
+
+    last = APR_BRIGADE_LAST(bb);
+    if (BUCKET_IS_SPOOL(last))
+        return ((apr_bucket_file *)last->data)->fd;
+
+    return NULL;
+}
 
 APREQ_DECLARE(apr_status_t) apreq_brigade_concat(apr_pool_t *pool,
                                                  const char *temp_dir,
@@ -812,9 +822,7 @@
         if (s != APR_SUCCESS)
             return s;
 
-        /* This cast, when out_len = -1, is intentional */
-        if ((apr_uint64_t)out_len < heap_limit)
-            s = apreq_brigade_fwrite(file, &wlen, out);
+        s = apreq_brigade_fwrite(file, &wlen, out);
 
         if (s != APR_SUCCESS)
             return s;
@@ -835,6 +843,9 @@
         if (s != APR_SUCCESS)
             return s;
     }
+
+    if (in == out)
+        return APR_SUCCESS;
 
     last_in = APR_BRIGADE_LAST(in);
 



Mime
View raw message