~ubuntu-branches/ubuntu/edgy/libapache2-mod-perl2/edgy

« back to all changes in this revision

Viewing changes to t/filter/TestFilter/in_init_basic.pm

  • Committer: Bazaar Package Importer
  • Author(s): Andres Salomon
  • Date: 2005-08-12 01:40:38 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050812014038-gjigefs55pqx4qc8
Tags: 2.0.1-3
Grr.  Really include perl.conf file; it got lost due to diff not
wanting to add an empty file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
use Apache::Test;
7
7
use Apache::TestUtil;
8
8
 
9
 
use Apache::RequestRec ();
10
 
use Apache::RequestIO ();
11
 
 
12
 
use base qw(Apache::Filter);
13
 
 
14
 
use Apache::Const -compile => qw(OK M_POST);
 
9
use Apache2::RequestRec ();
 
10
use Apache2::RequestIO ();
 
11
 
 
12
use base qw(Apache2::Filter);
 
13
 
 
14
use TestCommon::Utils ();
 
15
 
 
16
use Apache2::Const -compile => qw(OK M_POST);
15
17
 
16
18
use constant READ_SIZE  => 1024;
17
19
 
18
 
 
19
20
# this filter is expected to be called once
20
21
# it'll set a note, with the count
21
22
sub transparent_init : FilterInitHandler {
26
27
    $filter->r->notes->set(init => $ctx->{init});
27
28
    $filter->ctx($ctx);
28
29
 
29
 
    return Apache::OK;
 
30
    return Apache2::Const::OK;
30
31
}
31
32
 
32
33
# this filter passes the data through unmodified and sets a note
41
42
    $filter->r->notes->set(run => $ctx->{run});
42
43
    $filter->ctx($ctx);
43
44
 
44
 
    my $rv = $filter->next->get_brigade($bb, $mode, $block, $readbytes);
45
 
    return $rv unless $rv == APR::SUCCESS;
 
45
    $filter->next->get_brigade($bb, $mode, $block, $readbytes);
46
46
 
47
 
    return Apache::OK;
 
47
    return Apache2::Const::OK;
48
48
}
49
49
 
50
50
 
51
51
 
52
52
# this filter is not supposed to get a chance to run, since its init
53
53
# handler immediately removes it
54
 
sub suicide_init : FilterInitHandler { shift->remove(); Apache::OK }
 
54
sub suicide_init : FilterInitHandler { shift->remove(); Apache2::Const::OK }
55
55
sub suicide      : FilterHasInitHandler(\&suicide_init) {
56
56
    die "this filter is not supposed to have a chance to run";
57
57
}
61
61
 
62
62
    $r->content_type('text/plain');
63
63
 
64
 
    if ($r->method_number == Apache::M_POST) {
65
 
        $r->print(ModPerl::Test::read_post($r));
 
64
    if ($r->method_number == Apache2::Const::M_POST) {
 
65
        $r->print(TestCommon::Utils::read_post($r));
66
66
    }
67
67
 
68
68
    my @keys = qw(init run);
69
69
    my %times = map { $_ => $r->notes->get($_)||0 } @keys;
70
70
    $r->print("$_ $times{$_}\n") for @keys;
71
71
 
72
 
    Apache::OK;
 
72
    Apache2::Const::OK;
73
73
}
74
74
1;
75
75
__DATA__