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