Travelport / travelport-uapi-tutorial-php

The travelport-uapi-tutorial-php is a PHP project for Universal API that will help you connect and code a standard workflow including Air, Vehicle, and Hotel.
35 stars 47 forks source link

Implement gzip to request and response - PHP #8

Open ratheepan opened 8 years ago

ratheepan commented 8 years ago

Hello,

i am trying to sen request with gzip compression. but i could not get any success result.

And our server is already configured with gzip extension.

here header information for the request

response header

  Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Connection    Keep-Alive
  Content-Encoding  gzip
  Content-Type  text/html; charset=UTF-8
  Date  Tue, 29 Mar 2016 05:59:17 GMTExpires    
  Thu, 19 Nov 1981 08:52:00 GMTKeep-Alive   
  timeout=5, max=99
  Pragma    no-cache
  Server    Apache/2.2.22 (Ubuntu)
    Set-Cookie  ck_login_id_20=1; expires=Mon, 27-Jun-2016 05:59:17 GMT; path=/;    omain=104.43.11.233; httponly ck_login_language_20=en_us; expires=Mon, 27-Jun-2016 05:59:17 GMT; path=/;     domain=104.43.11.233; httponly

  sugar_user_theme=TravelNote_custom; expires=Wed, 29-Mar-2017 05:59:17 GMT; httponly
  Transfer-Encoding chunked
  Vary  Accept-Encoding
 X-Powered-By   PHP/5.3.10-1ubuntu3.21

request header

   Accept   text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
   Accept-Encoding  gzip, deflate
  Accept-Language   en-US,en;q=0.5
   Content-Length   743
  Content-Type  application/x-www-form-urlencoded; charset=UTF-8
  Cookie    sugar_user_theme=TravelNote_custom;      mailGridWidths=0=10&1=10&2=150&3=250&4=175&5=125; EmailTreeLayout

=732dca6d-95f2-b15b-ce39-568609a7faf7=false&7472241e-a5ee-7cff-3be3-566a7bfef705=false&83b84b33-4a21-b423-8bc3-566a7b0ce471 =false&9e677213-f8dc-7f1f-7024-566a7b7d2208=false&b8f761a9-e99e-8e09-9110-566a7b2799a6=false; ck_login_id_20 =1; ck_login_language_20=en_us; PHPSESSID=i6clh7cfkon0pvksp6e4jl0pd7 Host 104.43.11.233

Please find below the soap header in php

 if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");

 else ob_start();

    $auth = base64_encode("$CREDENTIALS");
    $soap_do = curl_init ($url);
    $header = array(
    "Content-Type: text/xml;charset=UTF-8",
    "Accept-Encoding: gzip", 
    "Cache-Control: no-cache",
    "Pragma: no-cache",
    "SOAPAction: \"\"",
    "Connection: Close",
    "Authorization: Basic $auth",
    "Content-length: ".strlen($message),

    );

            curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 60); 
            curl_setopt($soap_do, CURLOPT_TIMEOUT, 60); 
            curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); 
            curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); 
            curl_setopt($soap_do, CURLOPT_POST, true ); 
            curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message); 
            curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
            curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true); // this will prevent the curl_exec to return result and will let us to capture output

            curl_setopt($soap_do,CURLOPT_ENCODING , 1);

            return  $res =curl_exec($soap_do);  

Can you please help to fix this?

Thanks in advance

s ratheepan

vivekjyotipramanik commented 8 years ago

Hi Ratheepan,

I am checking and will provide an update soon. Thanks.

Thanks & Regards Vivekjyoti Pramanik