Zlib::Stream's get_pending doesn't do what the POE::Filter docs say it
should do, and Zlib doesn't have a get_pending. attached patch that
fixes this.
Subject: | pofizlib-api.diff |
diff --git a/lib/POE/Filter/Zlib.pm b/lib/POE/Filter/Zlib.pm
index c726880..2edd779 100644
--- a/lib/POE/Filter/Zlib.pm
+++ b/lib/POE/Filter/Zlib.pm
@@ -24,27 +24,18 @@ sub level {
$self->{level} = $level if defined $level;
}
-sub get {
- my ($self, $raw_lines) = @_;
- my $events = [];
-
- foreach my $raw_line (@$raw_lines) {
- if ( my $line = uncompress( $raw_line ) ) {
- push @$events, $line;
- }
- else {
- warn "Couldn\'t uncompress input: $raw_line\n";
- #push @$events, $raw_line;
- }
- }
- return $events;
-}
+# use inherited get() from POE::Filter
sub get_one_start {
my ($self, $raw_lines) = @_;
push @{ $self->{BUFFER} }, $_ for @{ $raw_lines };
}
+sub get_pending {
+ my $self = shift;
+ return $self->{BUFFER};
+}
+
sub get_one {
my $self = shift;
my $events = [];
@@ -142,6 +133,10 @@ Consult L<Compress::Zlib> for details.
Takes an arrayref which is contains lines of compressed input. Returns an arrayref of uncompressed lines.
+=item get_pending
+
+Returns any data in a filter's input buffer. The filter's input buffer is not cleared, however.
+
=item put
Takes an arrayref containing lines of uncompressed output, returns an arrayref of compressed lines.
diff --git a/lib/POE/Filter/Zlib/Stream.pm b/lib/POE/Filter/Zlib/Stream.pm
index b09d357..a2949c6 100644
--- a/lib/POE/Filter/Zlib/Stream.pm
+++ b/lib/POE/Filter/Zlib/Stream.pm
@@ -30,25 +30,13 @@ sub new {
return bless $buffer, $type;
}
+# use inherited get() from POE::Filter
+
sub get_one_start {
my ($self, $raw_lines) = @_;
$self->{BUFFER} .= join '', @{ $raw_lines };
}
-sub get_pending {
- my $self = shift;
- return unless length $self->{BUFFER};
-
- my @return;
- while(1) {
- my $next = $self->get_one();
- last unless @$next;
- push @return, @$next;
- }
-
- return \@return;
-}
-
sub get_one {
my $self = shift;
@@ -61,6 +49,11 @@ sub get_one {
return [ $out ];
}
+sub get_pending {
+ my $self = shift;
+ return $self->{BUFFER} ? [ $self->{BUFFER} ] : undef;
+}
+
sub put {
my ($self, $events) = @_;
my $raw_lines = [];