protected function exec(Url $url, array $options)
    {
        $connection = curl_init((string) $url);
        curl_setopt_array($connection, $options);

        $curl = new CurlResult($connection);

        //Get only text responses
        $curl->onHeader(function ($name, $value, $data) {
            if ($name === 'content-type') {
                $data->isBinary = !preg_match('/(text|html|json)/', strtolower($value));
            }
        });

        $curl->onBody(function ($string, stdClass $data) {
            return empty($data->isBinary);
        });

        curl_exec($connection);

        $result = $curl->getResult();

        curl_close($connection);

        return $this->responses[] = new Response(
            $url,
            Url::create($result['url']),
            $result['statusCode'],
            $result['contentType'],
            $result['content'],
            $result['headers'],
            $result['info']
        );
    }
protected function exec(Url $url, array $options)
    {
        $connection = curl_init((string) $url);
        curl_setopt_array($connection, $options);

        $curl = new CurlResult($connection);

        //Get only text responses
        $curl->onHeader(function ($name, $value, $data) {
            if ($name === 'content-type') {
                $data->isBinary = !preg_match('/(text|html|json)/', strtolower($value));
            }
        });

        $curl->onBody(function ($string, stdClass $data) {
            return empty($data->isBinary);
        });

        curl_exec($connection);

        $result = $curl->getResult();

        curl_close($connection);

        return $this->responses[] = new Response(
            $url,
            Url::create($result['url']),
            $result['statusCode'],
            $result['contentType'],
            $result['content'],
            $result['headers'],
            $result['info']
        );
    }
protected function exec ( Url $ url , array $ options ) { $ connection = curl_init ( ( string ) $ url ) ; curl_setopt_array ( $ connection , $ options ) ; $ curl = new CurlResult ( $ connection ) ; //Get only text responses $ curl -> onHeader ( function ( $ name , $ value , $ data ) { if ( $ name === 'content-type' ) { $ data -> isBinary = ! preg_match ( '/(text|html|json)/' , strtolower ( $ value ) ) ; } } ) ; $ curl -> onBody ( function ( $ string , stdClass $ data ) { return empty ( $ data -> isBinary ) ; } ) ; curl_exec ( $ connection ) ; $ result = $ curl -> getResult ( ) ; curl_close ( $ connection ) ; return $ this -> responses [ ] = new Response ( $ url , Url :: create ( $ result [ 'url' ] ) , $ result [ 'statusCode' ] , $ result [ 'contentType' ] , $ result [ 'content' ] , $ result [ 'headers' ] , $ result [ 'info' ] ) ; }
Execute a curl request

@param Url   $url
@param array $options

@return Response
Execute a curl request