<?php

/*
* @author Balaji
* @name Rainbow PHP Framework - PHP Script
* @copyright © 2017 ProThemes.Biz
*
*/

function compressionTest($site) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, $site);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
   	curl_setopt($ch, CURLOPT_ENCODING , "gzip");
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
    $response=curl_exec($ch);
    $comSize = curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $header = substr($response, 0, $header_size);
    $body = substr($response, $header_size);
    $unComSize = strlen($body);
    $gzdataSize = strlen(gzencode($body, 9));
    curl_close($ch);
    if(check_str_contains($header,"gzip"))
    $isGzip = true;
    else
    $isGzip = false;
    return array($comSize,$unComSize,$isGzip,$gzdataSize,$header,$body);
}

?>