Return-Path: Delivered-To: apmail-httpd-apreq-cvs-archive@www.apache.org Received: (qmail 60799 invoked from network); 18 Dec 2005 16:08:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Dec 2005 16:08:04 -0000 Received: (qmail 21271 invoked by uid 500); 18 Dec 2005 16:08:03 -0000 Delivered-To: apmail-httpd-apreq-cvs-archive@httpd.apache.org Received: (qmail 21231 invoked by uid 500); 18 Dec 2005 16:08:03 -0000 Mailing-List: contact apreq-cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: apreq-dev@httpd.apache.org List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list apreq-cvs@httpd.apache.org Received: (qmail 21216 invoked by uid 99); 18 Dec 2005 16:08:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Dec 2005 08:08:02 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 18 Dec 2005 08:08:01 -0800 Received: (qmail 60711 invoked by uid 65534); 18 Dec 2005 16:07:41 -0000 Message-ID: <20051218160741.60710.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r357474 - in /httpd/apreq/trunk/glue/perl/lib/Apache2: Cookie.pm Request.pm Upload.pm Date: Sun, 18 Dec 2005 16:07:40 -0000 To: apreq-cvs@httpd.apache.org From: joes@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: joes Date: Sun Dec 18 08:07:36 2005 New Revision: 357474 URL: http://svn.apache.org/viewcvs?rev=357474&view=rev Log: Remove stale Inline::Test stubs from Apache2::*. The tests are now in APR::Request::*, and these are single-env leftovers. Modified: httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm httpd/apreq/trunk/glue/perl/lib/Apache2/Request.pm httpd/apreq/trunk/glue/perl/lib/Apache2/Upload.pm Modified: httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm?rev=357474&r1=357473&r2=357474&view=diff ============================================================================== --- httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm (original) +++ httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm Sun Dec 18 08:07:36 2005 @@ -131,8 +131,6 @@ =head1 SYNOPSIS -=for example begin - use Apache2::Cookie; $j = Apache2::Cookie::Jar->new($r); @@ -145,13 +143,6 @@ $c_out->path("/bar"); # set path to "/bar" $c_out->bake; # send cookie in response headers -=for example end - -=for example_testing - ok "foo bar" eq join " ", keys %{$j->cookies}; - ok $c_out->as_string eq "mycookie=foo; path=/bar"; - ok $c_in->value == 1; - @@ -213,8 +204,6 @@ C will croak if the parser failed to successfully parse the "Cookie" header. -=for example begin - $c = Apache2::Cookie->new($r, name => "foo", value => 3); $j->cookies->add($c); @@ -222,16 +211,6 @@ @cookies = $j->cookies("foo"); # all foo cookies @names = $j->cookies(); # all cookie names -=for example end - -=for example_testing - ok @cookies == 2; - is $_ -> name, "foo" for $cookie, @cookies; - ok $cookies[0]->value eq $cookie->value; - ok $cookies[0]->value == 1; - ok $cookies[1]->value == 3; - is "@names", "foo bar"; - @@ -256,8 +235,6 @@ Just like CGI::Cookie::new, but requires an additional environment argument: -=for example begin - $cookie = Apache2::Cookie->new($r, -name => 'foo', -value => 'bar', @@ -267,15 +244,6 @@ -secure => 1 ); -=for example end - -=for example_testing - ok $cookie->name eq "foo", 'name eq "foo"'; - ok $cookie->value eq "bar", 'value eq "bar"'; - ok $cookie->domain eq ".capricorn.com", 'domain eq ".capricorn.com"'; - ok $cookie->path eq "/cgi-bin/database",'path eq "/cgi-bin/database"'; - ok $cookie->secure == 1, '$cookie->secure == 1'; - The C<-value> argument may be either an arrayref, a hashref, or a string. C encodes this argument into the cookie's raw value. @@ -291,15 +259,8 @@ manner compatible with CGI::Cookie (and Apache2::Cookie 1.X). This class method accepts an arrayref, hashref, or normal perl string in $value. -=for example begin - $value = Apache2::Cookie->freeze(["2+2", "=4"]); -=for example end - -=for example_testing - ok $value eq "2%2b2&%3d4", '$value eq "2%2b2&%3d4"'; - @@ -314,19 +275,9 @@ place of the cookie's raw value. This method can also decode cookie values created using CGI::Cookie or Apache2::Cookie 1.X. -=for example begin - print $cookie->thaw; # prints "bar" @values = Apache2::Cookie->thaw($value); # ( "2+2", "=4" ) -=for example end - -=for example_testing - ok $_STDOUT_ eq "bar", '$_STDOUT_ eq "bar"'; - ok @values == 2, '@values == 2'; - ok $values[0] eq "2+2", '$values[0] eq "2+2"'; - ok $values[1] eq "=4", '$values[1] eq "=4"'; - @@ -337,16 +288,8 @@ Format the cookie object as a string. The quote-operator for Apache2::Cookie is overloaded to run this method whenever a cookie appears in quotes. - -=for example begin - ok "$cookie" eq $cookie->as_string; -=for example end - -=for example_testing - ok substr("$cookie", 0, 8) eq "foo=bar;"; - @@ -356,9 +299,6 @@ Get the name of the cookie. -=for example_testing - ok $cookie->name eq "foo"; - @@ -368,24 +308,13 @@ Get the (unswizzled) value of the cookie: -=for example begin - my $value = $cookie->value; my @values = $cookie->value; -=for example end - -=for example_testing - ok @values == 1, '@values == 1'; - ok $value eq "bar", '$value eq "bar"'; - ok $values[0] eq "bar", '$values[0] eq "bar"'; - Note: if the cookie's value was created using a C method, one way to reconstitute the object is by subclassing Apache2::Cookie with a package that provides the associated C sub: -=for example begin - { package My::COOKIE; @ISA = 'Apache2::Cookie'; @@ -396,8 +325,6 @@ ok $cookie->value eq "BAR"; -=for example end - @@ -408,15 +335,8 @@ Gets the raw (opaque) value string as it appears in the incoming "Cookie" header. -=for example begin - ok $cookie->raw_value eq "bar"; -=for example end - -=for example_testing - # run the example, don't just compile it - @@ -438,8 +358,6 @@ - - =head2 domain $cookie->domain() @@ -447,17 +365,9 @@ Get or set the domain for the cookie: -=for example begin - $domain = $cookie->domain; $cookie->domain(".cp.net"); -=for example end - -=for example_testing - ok $domain eq ".capricorn.com"; - ok $cookie->domain eq ".cp.net"; - @@ -468,17 +378,9 @@ Get or set the path for the cookie: -=for example begin - $path = $cookie->path; $cookie->path("/"); -=for example end - -=for example_testing - ok $path eq "/cgi-bin/database"; - ok $cookie->path eq "/"; - @@ -491,17 +393,10 @@ Netscape spec cookies have version = 0; RFC-compliant cookies have version = 1. -=for example begin - ok $cookie->version == 0; $cookie->version(1); ok $cookie->version == 1; -=for example end - -=for example_testing - # run the example tests - @@ -517,17 +412,9 @@ omitted, the number is interpreted as representing seconds). As a special case, $set = "now" is equivalent to $set = "0". -=for example begin - my $expires = $cookie->expires; $cookie->expires("+3h"); # cookie is set to expire in 3 hours -=for example end - -=for example_testing - ok $expires == 3 * 30 * 24 * 3600; # 3 months - ok $cookie->expires == 3 * 3600; - @@ -538,18 +425,10 @@ Get or set the secure flag for the cookie: -=for example begin - $cookie->secure(1); $is_secure = $cookie->secure; $cookie->secure(0); -=for example end - -=for example_testing - ok $is_secure; - ok (not $cookie->secure); - @@ -560,16 +439,9 @@ Get or set the comment field of an RFC (Version > 0) cookie. -=for example begin - $cookie->comment("Never eat yellow snow"); print $cookie->comment; -=for example end - -=for example_testing - ok $_STDOUT_ eq "Never eat yellow snow"; - @@ -580,16 +452,9 @@ Get or set the commentURL field of an RFC (Version > 0) cookie. -=for example begin - $cookie->commentURL("http://localhost/cookie.policy"); print $cookie->commentURL; -=for example end - -=for example_testing - ok $_STDOUT_ eq "http://localhost/cookie.policy"; - @@ -599,19 +464,10 @@ Fetch and parse the incoming I header: -=for example begin - my $cookies = Apache2::Cookie->fetch($r); # APR::Request::Cookie::Table ref my %cookies = Apache2::Cookie->fetch($r); -=for example end - -=for example_testing - ok "foobarfoo" eq join "", keys %$cookies; - ok 123 == join "", map $_->value, values %$cookies; - ok "barfoo" eq join "", sort keys %cookies; # %cookies lost original foo cookie - ok 23 == join "", sort map $_->value, values %cookies; Modified: httpd/apreq/trunk/glue/perl/lib/Apache2/Request.pm URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/lib/Apache2/Request.pm?rev=357474&r1=357473&r2=357474&view=diff ============================================================================== --- httpd/apreq/trunk/glue/perl/lib/Apache2/Request.pm (original) +++ httpd/apreq/trunk/glue/perl/lib/Apache2/Request.pm Sun Dec 18 08:07:36 2005 @@ -39,39 +39,16 @@ Apache2::Request - Methods for dealing with client request data -=for testing - use Apache2::Request; - use Apache2::Upload; - use APR::Pool; - $r = APR::Pool->new; - $req = Apache2::Request->new($r); - $u = Apache2::Upload->new($r, name => "foo", file => __FILE__); - $req->body_status(0); - $req->parse; - $req->body->add($u); - $req->args->add(foo => 1); - $req->args->add(bar => 2); - $req->args->add(foo => 3); - =head1 SYNOPSIS -=for example begin - use Apache2::Request; $req = Apache2::Request->new($r); @foo = $req->param("foo"); $bar = $req->args("bar"); -=for example end - -=for example_testing - ok $req->isa("Apache2::Request"); - is "@foo", join " ", 1, 3, __FILE__; - is $bar, 2; - @@ -116,18 +93,9 @@ Creates a new Apache2::Request object. -=for example begin - my $req = Apache2::Request->new($r, POST_MAX => "1M"); -=for example end - -=for example_testing - ok ref $req; - ok $req->isa("Apache2::Request"); - - With mod_perl2, the environment object $r must be an Apache2::RequestRec object. In that case, all methods from Apache2::RequestRec are inherited. In the (default) CGI environment, $r must be an APR::Pool object. @@ -153,15 +121,11 @@ that supports I, the TEMP_DIR should be located on the same file system as the final destination file: -=for example begin - use Apache2::Upload; my $req = Apache2::Request->new($r, TEMP_DIR => "/home/httpd/tmp"); my $upload = $req->upload('file'); $upload->link("/home/user/myfile"); -=for example end - For more details on C, see L. @@ -179,8 +143,6 @@ Apache will automatically continue writing the original data to $upload->fh after the hook exits. -=for example begin - my $transparent_hook = sub { my ($upload, $data, $data_len, $hook_data) = @_; warn "$hook_data: got $data_len bytes for " . $upload->name; @@ -191,9 +153,6 @@ UPLOAD_HOOK => $transparent_hook, ); -=for example end - - =back @@ -224,8 +183,6 @@ mimicing the OO interface of C. -=for example begin - # similar to CGI.pm my $foo_value = $req->param('foo'); @@ -239,14 +196,6 @@ my $table = $req->param; @table_keys = keys %$table; -=for example end - -=for example_testing - is $foo_value, 1; - is "@foo_values", join " ", 1, 3, __FILE__; - is "@param_names", "foo bar"; - is "@table_keys", "foo bar foo foo"; - In list context, or when invoked with no arguments as C<< $req->param() >>, C induces libapreq2 to read @@ -269,8 +218,6 @@ has failed. In all other circumstances C will throw an Apache2::Request::Error object into $@ should either parser fail. -=for example begin - $req->args_status(1); # set error state for query-string parser ok $req->param_status == 1; @@ -284,11 +231,6 @@ $req->args_status(0); # reset query-string parser state to "success" -=for example end - -=for example_testing - # run example - Note: modifications to the C<< scalar $req->param() >> table only affect the returned table object (the underlying C apr_table_t is @@ -318,29 +260,13 @@ Returns an I object containing the POST data parameters of the I object. -=for example begin - my $body = $req->body; -=for example end - -=for example_testing - is join(" ", keys %$body), "foo"; - is join(" ", values %$body), __FILE__; - - An optional name parameter can be passed to return the POST data parameter associated with the given name: -=for example begin - my $foo_body = $req->body("foo"); -=for example end - -=for example_testing - is $foo_body, __FILE__; - More generally, C follows the same pattern as C with respect to its return values and argument list. The main difference is that modifications to the C<< scalar $req->body() >> table affect @@ -384,9 +310,6 @@ Get the I status code of the query-string parser. APR_SUCCESS on success, error otherwise. -=for testing - is $req->args_status, 0; # APR_SUCCESS - @@ -399,8 +322,6 @@ has more data to parse, APR_EINIT if no post data has been parsed, error otherwise. -=for testing - is $req->body_status, 0; # APR_SUCCESS @@ -417,12 +338,6 @@ In list context C returns the list C<(args_status, body_status)>. -=for testing - is scalar($req->param_status), - $req->args_status || $req->body_status; - is join(" ", $req->param_status), - join(" ", $req->args_status, $req->body_status); - @@ -436,10 +351,6 @@ return the two parsers' combined I status code $req->body_status || $req->args_status - -=for testing - is $req->parse, $req->body_status || $req->args_status; - However C should be avoided in most normal situations. For example, in a mod_perl content handler it is more efficient to write Modified: httpd/apreq/trunk/glue/perl/lib/Apache2/Upload.pm URL: http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/lib/Apache2/Upload.pm?rev=357474&r1=357473&r2=357474&view=diff ============================================================================== --- httpd/apreq/trunk/glue/perl/lib/Apache2/Upload.pm (original) +++ httpd/apreq/trunk/glue/perl/lib/Apache2/Upload.pm Sun Dec 18 08:07:36 2005 @@ -32,33 +32,12 @@ Apache2::Upload - Methods for dealing with file uploads. -=for testing - use APR::Pool; - use Apache2::Upload; - $r = APR::Pool->new; - $req = Apache2::Request->new($r); - $u = Apache2::Upload->new($r, name => "foo", file => __FILE__); - $req->body_status(0); - $req->parse; - $req->body->add(foo => "bar"); # dummy param with same name as upload - $req->body->add($u); - open(my $fh, __FILE__) or die $!; - binmode $fh; - { - local $/; - $data = <$fh>; - } - close $fh; - ok length $data == -s __FILE__; - $data =~ s{\r}{}g; =head1 SYNOPSIS -=for example begin - use Apache2::Upload; $req = Apache2::Request->new($r); @@ -75,17 +54,6 @@ my $io = $upload->io; print while <$io>; -=for example end - -=for example_testing - ok $upload->bb->length == $size; - $uploads = $req->upload(); - is (scalar keys %{$uploads}, 1, "found upload"); - is $_STDOUT_, $data; - is $fh_data, $data; - is $slurp_data, $data; - - @@ -113,9 +81,6 @@ The name of the HTML form element which generated the upload. -=for testing - is $u->name, "foo"; - @@ -127,9 +92,6 @@ some agents will submit the file's full pathname, while others may submit just the basename. -=for testing - is $u->filename, __FILE__; - @@ -158,19 +120,9 @@ syntactic sugar for the underlying C and C methods from APR::Request::Brigade. -=for example begin - $io = $upload->io; print while $io->read($_); # equivalent to: tied(*$io)->READ($_) -=for example end - -=for example_testing - is $_STDOUT_, $data; - $io = $upload->io; - $io->read($h{io}, $upload->size); - is $h{io}, $data, "autovivifying read"; - See L and L below for additional notes on their usage. @@ -192,9 +144,6 @@ Returns the size of the upload in bytes. -=for testing - is $u->size, -s __FILE__; - @@ -210,8 +159,6 @@ the upload's internal (apr_table_t) info table to the one C<$table> represents. -=for example begin - my $info = $upload->info; while (my($hdr_name, $hdr_value) = each %$info) { # ... @@ -220,11 +167,6 @@ # fetch upload's Content-Type header my $type = $upload->info->{"Content-type"}; -=for example end - -=for example_testing - is $type, "application/octet-stream"; - @@ -234,19 +176,12 @@ Returns the MIME type of the given I object. -=for example begin - my $type = $upload->type; #same as my $content_type = $upload->info->{"Content-Type"}; $content_type =~ s/;.*$//ms; -=for example end - -=for example_testing - is $type, $content_type; - @@ -257,14 +192,10 @@ To avoid recopying the upload's internal tempfile brigade on a *nix-like system, I will create a hard link to it: -=for example begin - my $upload = $req->upload('foo'); $upload->link("/path/to/newfile") or die sprintf "link from '%s' failed: $!", $upload->tempname; -=for example end - Typically the new name must lie on the same device and partition as the brigade's tempfile. If this or any other reason prevents the OS from linking the files, C will instead @@ -281,19 +212,8 @@ Reads the full contents of a file upload into the scalar argument. The return value is the length of the file. -=for example begin - my $size = $upload->slurp($contents); -=for example end - -=for example_testing - is $size, length $contents; - $upload->slurp($h{slurp}); - is $h{slurp}, $contents, "autovivifying slurp"; - $contents =~ s{\r}{}g; - is $contents, $data; - @@ -303,14 +223,7 @@ Provides the name of the spool file. -=for example begin - my $tempname = $upload->tempname; - -=for example end - -=for example_testing - like $tempname, qr/apreq.{6}$/;