Author: joes
Date: Sun Mar 13 11:03:44 2005
New Revision: 157349
URL: http://svn.apache.org/viewcvs?view=rev&rev=157349
Log:
Implement $table->do(), $req->disable_uploads.
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/README
httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache2/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.xs
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.pm
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.xs
Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/README
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/README?view=diff&r1=157348&r2=157349
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/README (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/README Sun Mar 13
11:03:44 2005
@@ -42,6 +42,11 @@
temp_dir
header_in
header_out
+ jar_status
+ args_status
+ body_status
+ param_status
+ disable_uploads
missing:
add_hook (requires APR::Request::Hook)
@@ -129,8 +134,9 @@
FIRSTKEY, NEXTKEY
param_class
uploads
+ do
missing:
- rest of const apr_table_t * API (do, etc)
+ rest of const apr_table_t * API
APR::Request::Brigade
methods:
@@ -153,13 +159,16 @@
upload_tempname
upload_io
upload_fh
-
+ disable_uploads
--------------------------------------------------
Current (pure-perl) Apache2:: module breakdown
--------------------------------------------------
Apache2::Request @ISA=(Apache2::RequestRec, APR::Request::Apache2)
+
+ ctor:
+ new
==================================================
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache2/Request.pm
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache2/Request.pm?view=diff&r1=157348&r2=157349
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache2/Request.pm
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache2/Request.pm
Sun Mar 13 11:03:44 2005
@@ -1,7 +1,33 @@
package Apache2::Request;
use APR::Request::Param;
-use APR::Request::Apache2 qw/args/;
+use APR::Request::Apache2 qw/args/; # XXX the args() override here is a bug.
use Apache2::RequestRec;
push our @ISA, qw/Apache2::RequestRec APR::Request::Apache2/;
+
+my %old_limits = (
+ post_max => "read_limit",
+ max_body => "read_limit",
+);
+
+sub new {
+ my $class = shift;
+ my $req = $class->APR::Request::Apache2::new(shift);
+ my %attrs = @_;
+
+ while (my ($k, $v) = each %attrs) {
+ $k =~ s/^-//;
+ my $method = $old_limits{lc($k)} || lc $k;
+ $req->$method($v);
+ }
+ return $req;
+}
+
+sub hook_data {die "hook_data not implemented yet"}
+sub upload_hook {die "upload_hook not implemented yet"}
+sub disable_uploads {
+ my ($req, $pool) = @_;
+ $pool ||= $req->pool;
+ $req->APR::Request::disable_uploads($pool);
+}
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=157348&r2=157349
==============================================================================
--- 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 Sun Mar
13 11:03:44 2005
@@ -41,16 +41,17 @@
ok t_cmp($result, "text/plain", "type");
}
-skip 1, "- config() API not yet implemented" for 1..2;
-exit 0;
-
{
+ skip 1, "- hook API not yet implemented";
+ last;
my $value = 'DataUpload' x 100;
my $result = UPLOAD_BODY("$location?test=hook", content => $value);
ok t_cmp($result, $value, "type");
}
+
{
my $value = 'DataUpload' x 100;
- my $result = UPLOAD_BODY("$location?test=disable_uploads", content =>
$value);
+ my $result =
UPLOAD_BODY("$location?test=disable_uploads;foo=bar1;foo=bar2",
+ content => $value);
ok t_cmp($result, "ok", "disabled uploads");
}
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=157348&r2=157349
==============================================================================
---
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
Sun Mar 13 11:03:44 2005
@@ -136,15 +136,13 @@
$r->print($upload->type);
}
elsif ($test eq 'disable_uploads') {
- $req->config(DISABLE_UPLOADS => 1);
+ $req->disable_uploads;
eval {my $upload = $req->upload('HTTPUPLOAD')};
- if (ref $@ eq "Apache2::Request::Error") {
+ if (ref $@ eq "APR::Request::Error") {
my $args = [EMAIL PROTECTED]>{_r}->args('test'); # checks _r is an
object ref
- my $upload = [EMAIL PROTECTED]>upload('HTTPUPLOAD'); # no
exception this time!
+ my $upload = [EMAIL PROTECTED]>body('HTTPUPLOAD'); # no exception
this time!
die "args test failed" unless $args eq $test;
$args = [EMAIL PROTECTED]>args;
-# $args->add("foo" => "bar1");
-# $args->add("foo" => "bar2");
my $test_string = "";
# MAGIC ITERATOR TESTS
@@ -172,7 +170,7 @@
}
- [EMAIL PROTECTED]>print("ok");
+ $req->print("ok");
}
}
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=157348&r2=157349
==============================================================================
---
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
Sun Mar 13 11:03:44 2005
@@ -279,3 +279,4 @@
PUTBACK;
}
+
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=157348&r2=157349
==============================================================================
---
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
Sun Mar 13 11:03:44 2005
@@ -1,5 +1,70 @@
#include "apreq_xs_tables.h"
#define TABLE_CLASS "APR::Request::Param::Table"
+static int apreq_xs_table_do_sub(void *data, const char *key,
+ const char *val)
+{
+ struct apreq_xs_do_arg *d = data;
+ apreq_param_t *p = apreq_value_to_param(val);
+ dTHXa(d->perl);
+ dSP;
+ SV *sv = apreq_xs_param2sv(aTHX_ p, d->pkg, d->parent);
+ int rv;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ EXTEND(SP,2);
+
+ PUSHs(sv_2mortal(newSVpvn(p->v.name, p->v.nlen)));
+ PUSHs(sv_2mortal(sv));
+
+ PUTBACK;
+ rv = call_sv(d->sub, G_SCALAR);
+ SPAGAIN;
+ rv = (1 == rv) ? POPi : 1;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ return rv;
+}
+
+static XS(apreq_xs_table_do)
+{
+ dXSARGS;
+ struct apreq_xs_do_arg d = { NULL, NULL, NULL, aTHX };
+ const apr_table_t *t;
+ int i, rv = 1;
+ SV *sv, *t_obj;
+ IV iv;
+ MAGIC *mg;
+
+ if (items < 2 || !SvROK(ST(0)) || !SvROK(ST(1)))
+ Perl_croak(aTHX_ "Usage: $object->do(\\&callback, @keys)");
+ sv = ST(0);
+
+ t_obj = apreq_xs_sv2object(aTHX_ sv, TABLE_CLASS, 't');
+ iv = SvIVX(t_obj);
+ t = INT2PTR(const apr_table_t *, iv);
+ mg = mg_find(t_obj, PERL_MAGIC_ext);
+ d.parent = mg->mg_obj;
+ d.pkg = mg->mg_ptr;
+ d.sub = ST(1);
+
+ if (items == 2) {
+ rv = apr_table_do(apreq_xs_table_do_sub, &d, t, NULL);
+ XSRETURN_IV(rv);
+ }
+
+ for (i = 2; i < items; ++i) {
+ const char *key = SvPV_nolen(ST(i));
+ rv = apr_table_do(apreq_xs_table_do_sub, &d, t, key, NULL);
+ if (rv == 0)
+ break;
+ }
+ XSRETURN_IV(rv);
+}
static int apreq_xs_table_keys(void *data, const char *key, const char *val)
{
@@ -329,6 +394,7 @@
);
newXS("APR::Request::Param::()", XS_APR__Request__Param_nil, file);
newXS("APR::Request::Param::(\"\"", XS_APR__Request__Param_value, file);
+ newXS("APR::Request::Param::Table::do", apreq_xs_table_do, file);
MODULE = APR::Request::Param PACKAGE = APR::Request::Param
@@ -659,3 +725,5 @@
parent, mg->mg_ptr, mg->mg_len);
OUTPUT:
RETVAL
+
+
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.pm
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.pm?view=diff&r1=157348&r2=157349
==============================================================================
---
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.pm
(original)
+++
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.pm
Sun Mar 13 11:03:44 2005
@@ -9,3 +9,9 @@
or die "Can't find method $_ in class $class";
}
}
+
+sub param_status {
+ my $req = shift;
+ return $req->args_status || $req->body_status if wantarray;
+ return ($req->args_status, $req->body_status);
+}
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.xs
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.xs?view=diff&r1=157348&r2=157349
==============================================================================
---
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.xs
(original)
+++
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Request.xs
Sun Mar 13 11:03:44 2005
@@ -173,3 +173,54 @@
OUTPUT:
RETVAL
+
+SV*
+jar_status(req)
+ APR::Request req
+ PREINIT:
+ const apr_table_t *t;
+
+ CODE:
+ RETVAL = apreq_xs_error2sv(aTHX_ apreq_jar(req, &t));
+
+ OUTPUT:
+ RETVAL
+
+SV*
+args_status(req)
+ APR::Request req
+ PREINIT:
+ const apr_table_t *t;
+
+ CODE:
+ RETVAL = apreq_xs_error2sv(aTHX_ apreq_args(req, &t));
+
+ OUTPUT:
+ RETVAL
+
+SV*
+body_status(req)
+ APR::Request req
+ PREINIT:
+ const apr_table_t *t;
+
+ CODE:
+ RETVAL = apreq_xs_error2sv(aTHX_ apreq_body(req, &t));
+
+ OUTPUT:
+ RETVAL
+
+SV*
+disable_uploads(req, pool)
+ APR::Request req
+ APR::Pool pool
+ PREINIT:
+ apreq_hook_t *h;
+ apr_status_t s;
+ CODE:
+ h = apreq_hook_make(pool, apreq_hook_disable_uploads, NULL, NULL);
+ s = apreq_hook_add(req, h);
+ RETVAL = apreq_xs_error2sv(aTHX_ s);
+
+ OUTPUT:
+ RETVAL