lib/Minify/JS/ClosureCompiler.php
protected function getResponse($postBody)
    {
        $allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));

        if ($allowUrlFopen) {
            $contents = file_get_contents($this->serviceUrl, false, stream_context_create(array(
                'http' => array(
                    'method' => 'POST',
                    'compilation_level' => 'SIMPLE',
                    'output_format' => 'text',
                    'output_info' => 'compiled_code',
                    'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n",
                    'content' => $postBody,
                    'max_redirects' => 0,
                    'timeout' => 15,
                )
            )));
        } elseif (defined('CURLOPT_POST')) {
            $ch = curl_init($this->serviceUrl);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
            $contents = curl_exec($ch);
            curl_close($ch);
        } else {
            throw new Minify_JS_ClosureCompiler_Exception(
               "Could not make HTTP request: allow_url_open is false and cURL not available"
            );
        }

        if (false === $contents) {
            throw new Minify_JS_ClosureCompiler_Exception(
               "No HTTP response from server"
            );
        }

        return trim($contents);
    }
protected function getResponse($postBody)
    {
        $allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));

        if ($allowUrlFopen) {
            $contents = file_get_contents($this->serviceUrl, false, stream_context_create(array(
                'http' => array(
                    'method' => 'POST',
                    'compilation_level' => 'SIMPLE',
                    'output_format' => 'text',
                    'output_info' => 'compiled_code',
                    'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n",
                    'content' => $postBody,
                    'max_redirects' => 0,
                    'timeout' => 15,
                )
            )));
        } elseif (defined('CURLOPT_POST')) {
            $ch = curl_init($this->serviceUrl);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
            $contents = curl_exec($ch);
            curl_close($ch);
        } else {
            throw new Minify_JS_ClosureCompiler_Exception(
               "Could not make HTTP request: allow_url_open is false and cURL not available"
            );
        }

        if (false === $contents) {
            throw new Minify_JS_ClosureCompiler_Exception(
               "No HTTP response from server"
            );
        }

        return trim($contents);
    }
protected function getResponse ( $ postBody ) { $ allowUrlFopen = preg_match ( '/1|yes|on|true/i' , ini_get ( 'allow_url_fopen' ) ) ; if ( $ allowUrlFopen ) { $ contents = file_get_contents ( $ this -> serviceUrl , false , stream_context_create ( array ( 'http' => array ( 'method' => 'POST' , 'compilation_level' => 'SIMPLE' , 'output_format' => 'text' , 'output_info' => 'compiled_code' , 'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n" , 'content' => $ postBody , 'max_redirects' => 0 , 'timeout' => 15 , ) ) ) ) ; } elseif ( defined ( 'CURLOPT_POST' ) ) { $ ch = curl_init ( $ this -> serviceUrl ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'Content-type: application/x-www-form-urlencoded' ) ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ postBody ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , false ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , 15 ) ; $ contents = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; } else { throw new Minify_JS_ClosureCompiler_Exception ( "Could not make HTTP request: allow_url_open is false and cURL not available" ) ; } if ( false === $ contents ) { throw new Minify_JS_ClosureCompiler_Exception ( "No HTTP response from server" ) ; } return trim ( $ contents ) ; }
Get the response for a given POST body

@param string $postBody
@return string
@throws Minify_JS_ClosureCompiler_Exception
Get the response for a given POST body