"Fossies" - the Fresh Open Source Software Archive

Member "mod_perl-2.0.11/t/filter/TestFilter/out_str_api.pm" (5 Oct 2019, 2318 Bytes) of package /linux/www/apache_httpd_modules/mod_perl-2.0.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "out_str_api.pm": 2.0.8_vs_2.0.9.

    1 # please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
    2 package TestFilter::out_str_api;
    3 
    4 # Test Apache2::FilterRec and Apache2::Filter accessors
    5 
    6 use strict;
    7 use warnings FATAL => 'all';
    8 
    9 use Apache2::RequestRec ();
   10 use Apache2::RequestIO ();
   11 use Apache2::Filter ();
   12 use Apache2::FilterRec ();
   13 
   14 use Apache::Test;
   15 use Apache::TestUtil;
   16 use Apache::TestRequest;
   17 
   18 use Apache2::Const -compile => 'OK';
   19 
   20 my $response_data = "blah blah blah";
   21 
   22 #XXX: else pp_untie complains:
   23 #untie attempted while %d inner references still exist
   24 sub Apache2::Filter::UNTIE {}
   25 sub Apache2::Filter::PRINTF {}
   26 
   27 sub handler {
   28     my $filter = shift;
   29 
   30     my $data = '';
   31     while ($filter->read(my $buffer, 1024)) {
   32         $data .= $buffer;
   33     }
   34 
   35     tie *STDOUT, $filter;
   36 
   37     plan tests => 8;
   38 
   39     ok t_cmp($data, $response_data, "response data");
   40 
   41     ok $filter->isa('Apache2::Filter');
   42 
   43     {
   44         my $frec = $filter->frec;
   45 
   46         ok $frec->isa('Apache2::FilterRec');
   47         ok t_cmp($frec->name, "modperl_request_output", '$frec->name');
   48 
   49         my $next = $filter->next;
   50         ok t_cmp($next->frec->name, "modperl_request_output",
   51                  '$filter->next->frec->name');
   52 
   53         $next = $next->next;
   54         # since we can't ensure that the next filter will be the same,
   55         # as it's not under control, just check that we get some name
   56         my $name = $next->frec->name;
   57         t_debug("next->next name: $name");
   58         ok $name;
   59     }
   60 
   61     my $r = $filter->r;
   62 
   63     ok $r->isa('Apache2::RequestRec');
   64 
   65     my $path = '/' . Apache::TestRequest::module2path(__PACKAGE__);
   66     ok t_cmp($r->uri, $path, "path");
   67 
   68     untie *STDOUT;
   69 
   70     # we have done the job
   71     $filter->remove;
   72 
   73     Apache2::Const::OK;
   74 }
   75 
   76 sub pass_through {
   77     return Apache2::Const::DECLINED;
   78 }
   79 
   80 sub response {
   81     my $r = shift;
   82 
   83     $r->content_type('text/plain');
   84     $r->puts($response_data);
   85 
   86     Apache2::Const::OK;
   87 }
   88 
   89 1;
   90 __DATA__
   91 <NoAutoConfig>
   92 PerlModule TestFilter::out_str_api
   93 <Location /TestFilter__out_str_api>
   94     SetHandler modperl
   95     PerlResponseHandler TestFilter::out_str_api::response
   96     PerlOutputFilterHandler TestFilter::out_str_api
   97     PerlOutputFilterHandler TestFilter::out_str_api::pass_through
   98 </Location>
   99 </NoAutoConfig>