Apache2-Filter-HTTPHeadersFixup

 view release on metacpan or  search on metacpan

lib/Apache2/Filter/HTTPHeadersFixup.pm  view on Meta::CPAN

sub context {
    my ($f) = shift;

    my $ctx = $f->ctx;
    unless ($ctx) {
        mydebug "filter context init";
        $ctx = {
            headers             => [],
            done_with_headers   => 0,
            seen_body_separator => 0,
            keepalives          => $f->c->keepalives,
        };
        # since we are going to manipulate the reference stored in
        # ctx, it's enough to store it only once, we will get the same
        # reference in the following invocations of that filter
        $f->ctx($ctx);
        return $ctx;
    }

    my $c = $f->c;
    if ($c->keepalive == Apache2::Const::CONN_KEEPALIVE &&
        $ctx->{done_with_headers} &&
        $c->keepalives > $ctx->{keepalives}) {

        mydebug "a new request resetting the input filter state";

        $ctx->{headers}             = [];
        $ctx->{done_with_headers}   = 0;
        $ctx->{seen_body_separator} = 0;
        $ctx->{keepalives} = $c->keepalives;
    }

    return $ctx;
}

sub handle_output {
    my($class, $f, $bb) = @_;

    my $ctx = context($f);

t/manip/in_append.t  view on Meta::CPAN

my $module = 'TestManip::in_append';
my $location = "/" . Apache::TestRequest::module2path($module);

Apache::TestRequest::scheme('http'); #force http for t/TEST -ssl
Apache::TestRequest::module($module);

my $config = Apache::Test::config();
my $hostport = Apache::TestRequest::hostport($config);
t_debug("connecting to $hostport");

my $keep_alive_times     = 3;
my $non_keep_alive_times = 3;
my $times = $non_keep_alive_times + $keep_alive_times + 1;

plan tests => 6 * $times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate() for 1..$non_keep_alive_times;

## try keepalive conns
Apache::TestRequest::user_agent(reset => 1, keep_alive => 1);
validate() for 1..$keep_alive_times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate();

# 6 sub-tests
sub validate {
    my $key = "Leech";
    my $val = "Hungry";

    {
        my $res = HEAD $location;

t/manip/in_modify.t  view on Meta::CPAN

my $module = 'TestManip::in_modify';
my $location = "/" . Apache::TestRequest::module2path($module);

Apache::TestRequest::scheme('http'); #force http for t/TEST -ssl
Apache::TestRequest::module($module);

my $config = Apache::Test::config();
my $hostport = Apache::TestRequest::hostport($config);
t_debug("connecting to $hostport");

my $keep_alive_times     = 3;
my $non_keep_alive_times = 3;
my $times = $non_keep_alive_times + $keep_alive_times + 1;

plan tests => 6 * $times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate() for 1..$non_keep_alive_times;

# try keepalive conns
Apache::TestRequest::user_agent(reset => 1, keep_alive => 1);
validate() for 1..$keep_alive_times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate();

# 6 sub-tests
sub validate {

    my $key = "Sign-Here";
    my $val = "DigSig";

    {
        my $res = HEAD $location, $key  => "";

t/manip/out_append.t  view on Meta::CPAN

my $module = 'TestManip::out_append';
my $location = "/" . Apache::TestRequest::module2path($module);

Apache::TestRequest::scheme('http'); #force http for t/TEST -ssl
Apache::TestRequest::module($module);

my $config = Apache::Test::config();
my $hostport = Apache::TestRequest::hostport($config);
t_debug("connecting to $hostport");

my $keep_alive_times     = 3;
my $non_keep_alive_times = 3;
my $times = $non_keep_alive_times + $keep_alive_times + 1;

plan tests => 6 * $times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate() for 1..$non_keep_alive_times;

# try keepalive conns
Apache::TestRequest::user_agent(reset => 1, keep_alive => 1);
validate() for 1..$keep_alive_times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate();

# 6 sub-tests
sub validate {

    my $key = "Leech";
    my $val = "Hungry";

    {
        my $res = HEAD $location;

t/manip/out_modify.t  view on Meta::CPAN

my $module = 'TestManip::out_modify';
my $location = "/" . Apache::TestRequest::module2path($module);

Apache::TestRequest::scheme('http'); #force http for t/TEST -ssl
Apache::TestRequest::module($module);

my $config = Apache::Test::config();
my $hostport = Apache::TestRequest::hostport($config);
t_debug("connecting to $hostport");

my $keep_alive_times     = 3;
my $non_keep_alive_times = 3;
my $times = $non_keep_alive_times + $keep_alive_times + 1;

plan tests => 6 * $times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate() for 1..$non_keep_alive_times;

# try keepalive conns
Apache::TestRequest::user_agent(reset => 1, keep_alive => 1);
validate() for 1..$keep_alive_times;

## try non-keepalive conn
Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
validate();

# 6 sub-tests
sub validate {
    my $key = "Sign-Here";
    my $val = "DigSig";

    {
        my $res = HEAD $location, $key  => "";



( run in 1.418 second using v1.01-cache-2.11-cpan-df04353d9ac )