Skip Menu |

This queue is for tickets about the SOAP-Lite CPAN distribution.

Report information
The Basics
Id: 122782
Status: resolved
Priority: 0/
Queue: SOAP-Lite

People
Owner: Nobody in particular
Requestors: KOCEASY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: 1.26



Subject: Problem with compression in server mode
Hi, when I try to enabled compression on server call in SOAP::Lite I get errors. I tried call to soap server via cURL: curl -v -k --header "Content-Type: text/xml;charset=UTF-8" -H 'Accept-Encoding: gzip,deflate' --data @test.xml ip_address It return: 'Content-Encoding => deflate' and some coded data. But when I add argument --compress to curl for automatically uncompressing files it show error. So problem is in response call which try to run Encode::encode agains on compressed files which return miss broken data. I attach simply patch "compression.patch" which remove this broken behaviour. In attached file test_compression.pl is how it proceed in actual code and why it is broken.
Subject: compression.patch
--- SOAP-Lite-1.20/lib/SOAP/Transport/HTTP.pm~ 2017-08-12 21:41:13.000000000 +0200 +++ SOAP-Lite-1.20/lib/SOAP/Transport/HTTP.pm 2017-08-12 21:42:06.000000000 +0200 @@ -507,7 +507,7 @@ && $encoding ? 'charset=' . lc($encoding) : () ), 'Content-Length' => SOAP::Utils::bytelength $response ), - ( $] > 5.007 ) + ( !$compressed && $] > 5.007 ) ? do { require Encode; Encode::encode( $encoding, $response ) } : $response, ) );
Subject: test_compression.pl
use Compress::Zlib; require Encode; require SOAP::Lite; my $xml =<<EOL; <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oair="https://qa.openair1.com:1443/OAirService"> <soapenv:Header> <SessionHeader xsi:type="perl:SessionHeader" xmlns:perl="http://namespaces.soaplite.com/perl"> <sessionId xsi:type="xsd:string">xxxx</sessionId> </SessionHeader> </soapenv:Header> <soapenv:Body> <oair:add soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <objects xsi:type="perl:ArrayOfoaBase" xmlns:perl="http://namespaces.soaplite.com/perl"/> </oair:add> </soapenv:Body> </soapenv:Envelope> EOL my $compress = Compress::Zlib::compress($xml); my $encoded = Encode::encode( 'utf-8', $compress); print "Compress: " . SOAP::Utils::bytelength($compress) . " Encoded:" . SOAP::Utils::bytelength($encoded); print " Difference strings: " . ($compress cmp $encoded) . "\n";
Better patch which fix also call encode of current response
Subject: SOAP-Lite_encode.patch
--- SOAP-Lite-1.2/lib/SOAP/Transport/HTTP.pm~ 2016-06-09 17:37:44.000000000 -0400 +++ SOAP-Lite-1.2/lib/SOAP/Transport/HTTP.pm 2017-08-15 08:05:53.516371893 -0400 @@ -488,6 +488,10 @@ && ( $self->options->{compress_threshold} || 0 ) < SOAP::Utils::bytelength $response; + if ($] > 5.007 && $encoding) { + $response = do { require Encode; Encode::encode( $encoding, $response ) }; + } + $response = Compress::Zlib::compress($response) if $compressed; # this next line does not look like a good test to see if something is multipart @@ -507,9 +511,7 @@ && $encoding ? 'charset=' . lc($encoding) : () ), 'Content-Length' => SOAP::Utils::bytelength $response ), - ( $] > 5.007 ) - ? do { require Encode; Encode::encode( $encoding, $response ) } - : $response, + $response, ) ); $self->response->headers->header( 'Content-Type' =>
Subject: Re: [rt.cpan.org #122782] Problem with compression in server mode
Date: Wed, 16 Aug 2017 03:29:22 +0000
To: bug-SOAP-Lite [...] rt.cpan.org
From: Fred Moyer <fred [...] redhotpenguin.com>
Can you make a PR against the github repo? https://github.com/redhotpenguin/soaplite On Tue, Aug 15, 2017 at 5:33 AM Igor Bujna via RT <bug-SOAP-Lite@rt.cpan.org> wrote: Show quoted text
> Queue: SOAP-Lite > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=122782 > > > Better patch which fix also call encode of current response > > >
Fixed in 1.26