Archive

Archive for December, 2008

gzip nusoap requests

December 17th, 2008 2 comments

Recently for a project involving travelport xml api integration, we badly needed the soap requests to be gzipped, since the technical support people suggested. Also we were aware of the benefits of using gzEncoded data when transmitting through the Internet. For the same we checked the wid internet searching with all sort of combinations of gzip nusoap request. Speaking from the inner view, we already had developed a handful of classes to abstract the SubmitXML api provided by Galelio Travelport. And frankly were reluctant to trash all the code already written.
At this point, we swam through the whole code of nusoap.php; should say thanks to easyeclipse, and made some minor tweaks here and there. The following was all that was required, though I doubt if this would be a generic solution, this definitely serves our purpose and the versions we used are 0.7.3/Revision: 1.114.

in class soap_transport_http added property gzipRequests (line 2148)
var $gzipRequests = true; // gzip any requests..

in function buildPayload at the top (line 2799)
if($this->gzipRequests){
$data = gzencode($data);
$this->setHeader("Content-Encoding",'gzip');
}

in function sendRequest (about line 2874), just in case the request is using curl
if($this->gzipRequests){
$data = gzencode($data);
}

Categories: PHP, Tips Tags: