SOAP-Transport-HTTP.pm.diff [plain text]
--- SOAP-Lite-0.69/lib/SOAP/Transport/HTTP.pm 2007-08-31 18:42:47.000000000 +0000
+++ /tmp/HTTP.pm 2007-08-31 18:42:41.000000000 +0000
@@ -102,7 +102,6 @@
$endpoint ||= $self->endpoint;
my $method = 'POST';
- $COMPRESS = 'gzip';
$self->options->{is_compress}
||= exists $self->options->{compress_threshold}
@@ -172,9 +171,8 @@
# allow compress if present and let server know we could handle it
- $self->http_request->header('Accept-Encoding' =>
- [$SOAP::Transport::HTTP::Client::COMPRESS])
- if $self->options->{is_compress};
+ $self->http_request->header('Accept-Encoding' => ['gzip', 'deflate' ])
+ if $self->options->{is_compress};
$self->http_request->content_encoding($SOAP::Transport::HTTP::Client::COMPRESS)
if $compressed;
@@ -224,14 +222,18 @@
$self->is_success($self->http_response->is_success);
$self->status($self->http_response->status_line);
- my $content =
- ($self->http_response->content_encoding || '')
- =~ /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o &&
- $self->options->{is_compress} ?
- Compress::Zlib::memGunzip($self->http_response->content)
- : ($self->http_response->content_encoding || '') =~ /\S/
- ? die "Can't understand returned Content-Encoding (@{[$self->http_response->content_encoding]})\n"
- : $self->http_response->content;
+ my $content;
+ my $contentEncoding = ($self->http_response->content_encoding || '');
+ if ( $self->options->{is_compress} && $contentEncoding =~ 'gzip' ) {
+ $content = Compress::Zlib::memGunzip($self->http_response->content);
+ } elsif ( $self->options->{is_compress} && $contentEncoding =~ 'deflate' ) {
+ $content = Compress::Zlib::uncompress($self->http_response->content);
+ } elsif ( $self->options->{is_compress} && $contentEncoding =~ /\S/ ) {
+ die "Can't understand returned Content-Encoding (@{[$self->http_response->content_encoding]})\n";
+ } else {
+ $content = $self->http_response->content;
+ }
+
$self->http_response->content_type =~ m!^multipart/!i ?
join("\n", $self->http_response->headers_as_string, $content)
: $content;
@@ -350,10 +352,21 @@
$self->options->{is_compress} ||=
exists $self->options->{compress_threshold} && eval { require Compress::Zlib };
- 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;
+ my $compressed;
+ if ($self->options->{is_compress} && ($self->options->{compress_threshold} || 0) < SOAP::Utils::bytelength $response) {
+ foreach my $ce ( split( ',', $self->request->header('Accept-Encoding') ) ) {
+ if ( $ce =~ /\b(gzip|\*)\b/ ) {
+ $response = Compress::Zlib::memGzip($response);
+ $compressed = 'gzip';
+ last;
+ } elsif ( $ce =~ /\b(deflate|\*)\b/ ) {
+ $response = Compress::Zlib::compress($response);
+ $compressed = 'deflate';
+ last;
+ }
+ }
+ }
+
# 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);
@@ -361,7 +374,7 @@
$code => undef,
HTTP::Headers->new(
'SOAPServer' => $self->product_tokens,
- $compressed ? ('Content-Encoding' => $COMPRESS) : (),
+ $compressed ? ('Content-Encoding' => $compressed) : (),
'Content-Type' => join('; ', 'text/xml',
!$SOAP::Constants::DO_NOT_USE_CHARSET &&
$encoding ? 'charset=' . lc($encoding) : ()),