1--- SOAP-Lite-0.69/lib/SOAP/Transport/HTTP.pm 2007-08-31 18:42:47.000000000 +0000 2+++ /tmp/HTTP.pm 2007-08-31 18:42:41.000000000 +0000 3@@ -102,7 +102,6 @@ 4 $endpoint ||= $self->endpoint; 5 6 my $method = 'POST'; 7- $COMPRESS = 'gzip'; 8 9 $self->options->{is_compress} 10 ||= exists $self->options->{compress_threshold} 11@@ -172,9 +171,8 @@ 12 13 14 # allow compress if present and let server know we could handle it 15- $self->http_request->header('Accept-Encoding' => 16- [$SOAP::Transport::HTTP::Client::COMPRESS]) 17- if $self->options->{is_compress}; 18+ $self->http_request->header('Accept-Encoding' => ['gzip', 'deflate' ]) 19+ if $self->options->{is_compress}; 20 $self->http_request->content_encoding($SOAP::Transport::HTTP::Client::COMPRESS) 21 if $compressed; 22 23@@ -224,14 +222,18 @@ 24 $self->is_success($self->http_response->is_success); 25 $self->status($self->http_response->status_line); 26 27- my $content = 28- ($self->http_response->content_encoding || '') 29- =~ /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o && 30- $self->options->{is_compress} ? 31- Compress::Zlib::memGunzip($self->http_response->content) 32- : ($self->http_response->content_encoding || '') =~ /\S/ 33- ? die "Can't understand returned Content-Encoding (@{[$self->http_response->content_encoding]})\n" 34- : $self->http_response->content; 35+ my $content; 36+ my $contentEncoding = ($self->http_response->content_encoding || ''); 37+ if ( $self->options->{is_compress} && $contentEncoding =~ 'gzip' ) { 38+ $content = Compress::Zlib::memGunzip($self->http_response->content); 39+ } elsif ( $self->options->{is_compress} && $contentEncoding =~ 'deflate' ) { 40+ $content = Compress::Zlib::uncompress($self->http_response->content); 41+ } elsif ( $self->options->{is_compress} && $contentEncoding =~ /\S/ ) { 42+ die "Can't understand returned Content-Encoding (@{[$self->http_response->content_encoding]})\n"; 43+ } else { 44+ $content = $self->http_response->content; 45+ } 46+ 47 $self->http_response->content_type =~ m!^multipart/!i ? 48 join("\n", $self->http_response->headers_as_string, $content) 49 : $content; 50@@ -350,10 +352,21 @@ 51 $self->options->{is_compress} ||= 52 exists $self->options->{compress_threshold} && eval { require Compress::Zlib }; 53 54- my $compressed = $self->options->{is_compress} && 55- grep(/\b($COMPRESS|\*)\b/, $self->request->header('Accept-Encoding')) && 56- ($self->options->{compress_threshold} || 0) < SOAP::Utils::bytelength $response; 57- $response = Compress::Zlib::compress($response) if $compressed; 58+ my $compressed; 59+ if ($self->options->{is_compress} && ($self->options->{compress_threshold} || 0) < SOAP::Utils::bytelength $response) { 60+ foreach my $ce ( split( ',', $self->request->header('Accept-Encoding') ) ) { 61+ if ( $ce =~ /\b(gzip|\*)\b/ ) { 62+ $response = Compress::Zlib::memGzip($response); 63+ $compressed = 'gzip'; 64+ last; 65+ } elsif ( $ce =~ /\b(deflate|\*)\b/ ) { 66+ $response = Compress::Zlib::compress($response); 67+ $compressed = 'deflate'; 68+ last; 69+ } 70+ } 71+ } 72+ 73 # this next line does not look like a good test to see if something is multipart 74 # perhaps a /content-type:.*multipart\//gi is a better regex? 75 my ($is_multipart) = ($response =~ /content-type:.* boundary="([^\"]*)"/im); 76@@ -361,7 +374,7 @@ 77 $code => undef, 78 HTTP::Headers->new( 79 'SOAPServer' => $self->product_tokens, 80- $compressed ? ('Content-Encoding' => $COMPRESS) : (), 81+ $compressed ? ('Content-Encoding' => $compressed) : (), 82 'Content-Type' => join('; ', 'text/xml', 83 !$SOAP::Constants::DO_NOT_USE_CHARSET && 84 $encoding ? 'charset=' . lc($encoding) : ()), 85