stas 2004/03/15 16:59:45
Modified: src/modules/perl modperl_filter.c
. Changes
Added: t/filter in_str_bin_data.t
t/filter/TestFilter in_str_bin_data.pm
Log:
The filter streaming API print() function, now correctly handles a
binary data
Revision Changes Path
1.1 modperl-2.0/t/filter/in_str_bin_data.t
Index: in_str_bin_data.t
===================================================================
use strict;
use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;
plan tests => 4;
my $base = "/TestFilter__in_str_bin_data";
my @locations = map {$base . $_ } ('', '_filter');
my $expected = "123\001456\000789";
# test the binary data read/print w/ and w/o pass through filter
for my $location (@locations) {
my $received = POST_BODY_ASSERT $location, content => $expected;
ok t_cmp(length($expected),
length($received),
"$location binary response length");
ok t_cmp($expected,
$received,
"$location binary response data");
open my $fh, ">>/tmp/dat" or die $!;
print $fh "$received\n";
close $fh;
}
1.1 modperl-2.0/t/filter/TestFilter/in_str_bin_data.pm
Index: in_str_bin_data.pm
===================================================================
package TestFilter::in_str_bin_data;
# test that $r->print correctly handles binary data (e.g. doesn't
# truncate on "\0" if there is more data after it)
use strict;
use warnings FATAL => 'all';
use Apache::RequestIO ();
use Apache::RequestRec ();
use Apache::Filter ();
use Apache::TestTrace;
use Apache::Const -compile => qw(OK M_POST);
sub pass_through {
my $f = shift;
while ($f->read(my $buffer, 1024)) {
debug "read: " . length ($buffer) . "b [$buffer]";
$f->print($buffer);
}
return Apache::OK;
}
sub handler {
my $r = shift;
if ($r->method_number == Apache::M_POST) {
my $data = ModPerl::Test::read_post($r);
my $length = length $data;
debug "pass through $length bytes of $data\n";
$r->print($data);
}
Apache::OK;
}
1;
__END__
<NoAutoConfig>
PerlModule TestFilter::in_str_bin_data
<Location /TestFilter__in_str_bin_data_filter>
PerlInputFilterHandler TestFilter::in_str_bin_data::pass_through
SetHandler modperl
PerlResponseHandler TestFilter::in_str_bin_data
</Location>
<Location /TestFilter__in_str_bin_data>
SetHandler modperl
PerlResponseHandler TestFilter::in_str_bin_data
</Location>
</NoAutoConfig>
1.87 +1 -1 modperl-2.0/src/modules/perl/modperl_filter.c
Index: modperl_filter.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -u -r1.86 -r1.87
--- modperl_filter.c 4 Mar 2004 06:01:07 -0000 1.86
+++ modperl_filter.c 16 Mar 2004 00:59:45 -0000 1.87
@@ -783,7 +783,7 @@
apr_size_t *len)
{
apr_bucket_alloc_t *ba = filter->f->c->bucket_alloc;
- char *copy = apr_pstrndup(filter->pool, buf, *len);
+ char *copy = apr_pmemdup(filter->pool, buf, *len);
apr_bucket *bucket = apr_bucket_transient_create(copy, *len, ba);
/* MP_TRACE_f(MP_FUNC, "writing %d bytes: %s\n", *len, copy); */
MP_TRACE_f(MP_FUNC, MP_FILTER_NAME_FORMAT
1.348 +3 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.347
retrieving revision 1.348
diff -u -u -r1.347 -r1.348
--- Changes 10 Mar 2004 23:19:44 -0000 1.347
+++ Changes 16 Mar 2004 00:59:45 -0000 1.348
@@ -12,6 +12,9 @@
=item 1.99_14-dev
+The filter streaming API print() function, now correctly handles a
+binary data [Stas]
+
Fix Registry handlers, not to lose the execution errors, when they
include END blocks [Stas]