<commit_before>package TestFilter::out_bbs_basic;

use strict;
use warnings FATAL => 'all';

use Apache::Test;

use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::Filter ();
use APR::Brigade ();
use APR::Bucket ();

use Apache::Const -compile => 'OK';

#XXX: Not implemented yet, required by Test.pm
sub Apache::TestToString::PRINTF {}

sub handler {
    my($filter, $bb) = @_;

    unless ($filter->ctx) {

        Apache::TestToString->start;

        plan tests => 4;

        my $ba = $filter->r->connection->bucket_alloc;

        #should only have 1 bucket from the response() below
        for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
            ok $bucket->type->name;
            ok $bucket->length == 2;
            $bucket->read(my $data);
            ok (defined $data and $data eq 'ok');
        }

        my $tests = Apache::TestToString->finish;

        my $brigade = APR::Brigade->new($filter->r->pool, $ba);
        my $bucket = APR::Bucket->new($tests);

        $brigade->insert_tail($bucket);

        my $ok = $brigade->first->type->name =~ /mod_perl/ ? 4 : 0;
        $brigade->insert_tail(APR::Bucket->new("ok $ok\n"));

        $filter->next->pass_brigade($brigade);

        $filter->ctx(1); # flag that we have run this already
    }

    Apache::OK;
}<commit_msg>insert eos bucket when ignoring eos buckets on read PR: Obtained from: Submitted by: Reviewed by:<commit_after>package TestFilter::out_bbs_basic;

use strict;
use warnings FATAL => 'all';

use Apache::Test;

use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::Filter ();
use APR::Brigade ();
use APR::Bucket ();

use Apache::Const -compile => 'OK';

#XXX: Not implemented yet, required by Test.pm
sub Apache::TestToString::PRINTF {}

sub handler {
    my($filter, $bb) = @_;

    unless ($filter->ctx) {

        Apache::TestToString->start;

        plan tests => 4;

        my $ba = $filter->r->connection->bucket_alloc;

        #should only have 1 bucket from the response() below
        for (my $bucket = $bb->first; $bucket; $bucket = $bb->next($bucket)) {
            ok $bucket->type->name;
            ok $bucket->length == 2;
            $bucket->read(my $data);
            ok (defined $data and $data eq 'ok');
        }

        my $tests = Apache::TestToString->finish;

        my $brigade = APR::Brigade->new($filter->r->pool, $ba);
        my $bucket = APR::Bucket->new($tests);

        $brigade->insert_tail($bucket);

        my $ok = $brigade->first->type->name =~ /mod_perl/ ? 4 : 0;
        $brigade->insert_tail(APR::Bucket->new("ok $ok\n"));

        $brigade->insert_tail(APR::Bucket::eos_create($ba));

        $filter->next->pass_brigade($brigade);

        $filter->ctx(1); # flag that we have run this already
    }

    Apache::OK;
}
{'fraction_non_alphanumeric': 0.1717638691322902, 'fraction_numerical': 0.004267425320056899, 'mean_word_length': 2.796221322537112, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3613063', 'n_tokens_mistral': 939, 'n_tokens_neox': 890, 'n_words': 226}