The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Data::Transform::Zlib - A Filter for RFC195[0-2]


Data::Transform::Zlib provides a filter for performing (de-)compression using Compress::Raw::Zlib. Since it is just a wrapper around that module, it supports the same features.


Data::Transform::Zlib implements the standard Data::Transform API. Only additions and differences are documented here.


new() creates a new object. It accepts the following named parameters:


A hashref containing parameters suitable to pass to Compress::Raw::Zlib::Inflate().


A hashref containing parameters suitable to pass to Compress::Raw::Zlib::Deflate().

The only really interesting thing to set here is -WindowBits. If you set it to WANT_GZIP (symbol exported by Compress::Raw::Zlib), it will use gzip compression instead of zlib.

See the Compress::Raw::Zlib documentation for more details.


Due to how the zlib protocol works, it is important that you don't forget to close the stream by sending a Data::Transform::Meta::EOF packet when you're writing data. Otherwise the filter might be holding back data while waiting to see if additional data may help compression.

In case you're using this in a request/response protocol like XMPP (with stream compression enabled), you will also have to send a Data::Transform::Meta packet with the string "sync" as the content after each request/response. This makes the filter flush what is in its buffer, so you can be sure your request or response gets sent out. Otherwise, the filter might be waiting for more input to see whether it can compress the data even better, while you need the packet sent so you can get an answer from the remote side.


Data::Transform::Zlib was adapted from the POE::Filter::Zlib filter which was written by Chris Williams <>

Martijn van Beers <> did the adapting and maintains it.


Copyright (c) Chris Williams and Martijn van Beers.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU GPL, version 3.0 or higher.