Subject: | SOAP-Lite compression gzip vs deflate |
Date: | Wed, 29 Nov 2006 20:41:47 +0300 |
To: | bug-SOAP-Lite [...] rt.cpan.org |
From: | Dmitriy Kozlov <dimka [...] elnet.ru> |
SOAP-Lite-0.69 cant establish HTTP compression with yourself, because gzip vs deflate.
patch (below) make gzip compression available and strip deflate at all..
-- my client code --
my $client = new SOAP::Lite
uri => 'http://localhost/SoapTros',
proxy => 'http://localhost:8001/',
on_fault => sub {
debug($my_type, "Server communication error\n");
};
# enable compressing for our POST
$client->proxy('http://localhost:8001/', options => {compress_threshold => 100});
--- my server code --
my $daemon = SOAP::Transport::HTTP::Daemon
-> new(LocalAddr => 'localhost', LocalPort => 8001, Reuse => 1)
-> options({compress_threshold => 100})
-> dispatch_to('SoapTros');
--- /usr/lib/perl5/site_perl/5.8.7/SOAP/Transport/HTTP.pm.orig 2006-11-29 19:40:42.000000000 +0300
+++ /usr/lib/perl5/site_perl/5.8.7/SOAP/Transport/HTTP.pm 2006-11-29 19:43:27.000000000 +0300
@@ -27,7 +27,7 @@
@ISA = qw(SOAP::Client);
#@ISA = ("SOAP::Client",$USERAGENT_CLASS);
-$COMPRESS = 'deflate';
+$COMPRESS = 'gzip';
my(%redirect, %mpost, %nocompress);
@@ -246,7 +246,7 @@
use URI;
-$COMPRESS = 'deflate';
+$COMPRESS = 'gzip';
sub DESTROY { SOAP::Trace::objects('()') }
@@ -322,7 +322,7 @@
# TODO - this should query SOAP::Packager to see what types it supports,
# I don't like how this is hardcoded here.
my $content = $compressed ?
- Compress::Zlib::uncompress($self->request->content)
+ Compress::Zlib::memGunzip($self->request->content)
: $self->request->content;
my $response = $self->SUPER::handle(
$self->request->content_type =~ m!^multipart/! ?
@@ -354,7 +354,7 @@
my $compressed = $self->options->{is_compress} &&
grep(/\b($COMPRESS|\*)\b/, $self->request->header('Accept-Encoding')) &&
($self->options->{compress_threshold} || 0) < SOAP::Utils::bytelength $response;
- $response = Compress::Zlib::compress($response) if $compressed;
+ $response = Compress::Zlib::memGzip($response) if $compressed;
# this next line does not look like a good test to see if something is multipart
# perhaps a /content-type:.*multipart\//gi is a better regex?
my ($is_multipart) = ($response =~ /content-type:.* boundary="([^\"]*)"/im);