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

« back to all changes in this revision

Viewing changes to t/filter/TestFilter/in_bbs_body.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:
3
3
use strict;
4
4
use warnings FATAL => 'all';
5
5
 
6
 
use base qw(Apache::Filter); #so we inherit MODIFY_CODE_ATTRIBUTES
 
6
use base qw(Apache2::Filter); #so we inherit MODIFY_CODE_ATTRIBUTES
7
7
 
8
 
use Apache::RequestRec ();
9
 
use Apache::RequestIO ();
 
8
use Apache2::RequestRec ();
 
9
use Apache2::RequestIO ();
10
10
use APR::Brigade ();
11
11
use APR::Bucket ();
12
12
 
13
 
use Apache::Const -compile => qw(OK M_POST);
 
13
use TestCommon::Utils ();
 
14
 
 
15
use Apache2::Const -compile => qw(OK M_POST);
14
16
use APR::Const -compile => ':common';
15
17
 
16
18
sub handler : FilterRequestHandler {
17
19
    my($filter, $bb, $mode, $block, $readbytes) = @_;
18
20
 
19
 
    #warn "Called!";
20
 
    my $ba = $filter->r->connection->bucket_alloc;
21
 
 
22
 
    my $ctx_bb = APR::Brigade->new($filter->r->pool, $ba);
23
 
 
24
 
    my $rv = $filter->next->get_brigade($ctx_bb, $mode, $block, $readbytes);
25
 
 
26
 
    if ($rv != APR::SUCCESS) {
27
 
        return $rv;
28
 
    }
29
 
 
30
 
    while (!$ctx_bb->empty) {
31
 
        my $data;
32
 
        my $bucket = $ctx_bb->first;
33
 
 
34
 
        $bucket->remove;
35
 
 
36
 
        if ($bucket->is_eos) {
37
 
            #warn "EOS!!!!";
38
 
            $bb->insert_tail($bucket);
39
 
            last;
40
 
        }
41
 
 
42
 
        my $status = $bucket->read($data);
43
 
        #warn "DATA bucket!!!!";
44
 
        if ($status != APR::SUCCESS) {
45
 
            return $status;
46
 
        }
47
 
 
48
 
        if ($data) {
 
21
    $filter->next->get_brigade($bb, $mode, $block, $readbytes);
 
22
 
 
23
    for (my $b = $bb->first; $b; $b = $bb->next($b)) {
 
24
 
 
25
        last if $b->is_eos;
 
26
 
 
27
        if ($b->read(my $data)) {
49
28
            #warn"[$data]\n";
50
 
            $bucket = APR::Bucket->new(scalar reverse $data);
 
29
            my $nb = APR::Bucket->new($bb->bucket_alloc, scalar reverse $data);
 
30
            $b->insert_before($nb);
 
31
            $b->delete;
 
32
            $b = $nb;
51
33
        }
52
 
 
53
 
        $bb->insert_tail($bucket);
54
34
    }
55
35
 
56
 
    Apache::OK;
 
36
    Apache2::Const::OK;
57
37
}
58
38
 
59
39
sub response {
61
41
 
62
42
    $r->content_type('text/plain');
63
43
 
64
 
    if ($r->method_number == Apache::M_POST) {
65
 
        my $data = ModPerl::Test::read_post($r);
 
44
    if ($r->method_number == Apache2::Const::M_POST) {
 
45
        my $data = TestCommon::Utils::read_post($r);
66
46
        $r->puts($data);
67
47
    }
68
48
    else {
69
 
        $r->puts("1..1\nok 1\n");
 
49
        $r->puts("1..3\nok 1\n");
70
50
    }
71
51
 
72
 
    Apache::OK;
 
52
    Apache2::Const::OK;
73
53
}
74
54
 
75
55
1;