src/Request/CurlRequestUtil.php
public function request(string $url, array $requestHeaders = [], $returnResponseHeaders = false)
    {
        $handle = $this->createCurlHandle($url);

        if ($proxy = Config::get('hpProxy')) {
            $handle->setOption(CURLOPT_PROXY, $proxy);
        }

        if (!empty($requestHeaders)) {
            $handle->setOption(CURLOPT_HTTPHEADER, $this->prepareHeaders($requestHeaders));
        }

        if ($returnResponseHeaders) {
            $handle->setOption(CURLOPT_HEADER, true);
        }

        $response = $handle->execute();
        $statusCode = $handle->getInfo(CURLINFO_HTTP_CODE);
        $handle->close();

        if ($response && $returnResponseHeaders) {
            return $this->splitResponseHeaderAndBody($response, $statusCode);
        }

        return $response;
    }
public function request(string $url, array $requestHeaders = [], $returnResponseHeaders = false)
    {
        $handle = $this->createCurlHandle($url);

        if ($proxy = Config::get('hpProxy')) {
            $handle->setOption(CURLOPT_PROXY, $proxy);
        }

        if (!empty($requestHeaders)) {
            $handle->setOption(CURLOPT_HTTPHEADER, $this->prepareHeaders($requestHeaders));
        }

        if ($returnResponseHeaders) {
            $handle->setOption(CURLOPT_HEADER, true);
        }

        $response = $handle->execute();
        $statusCode = $handle->getInfo(CURLINFO_HTTP_CODE);
        $handle->close();

        if ($response && $returnResponseHeaders) {
            return $this->splitResponseHeaderAndBody($response, $statusCode);
        }

        return $response;
    }
public function request ( string $ url , array $ requestHeaders = [ ] , $ returnResponseHeaders = false ) { $ handle = $ this -> createCurlHandle ( $ url ) ; if ( $ proxy = Config :: get ( 'hpProxy' ) ) { $ handle -> setOption ( CURLOPT_PROXY , $ proxy ) ; } if ( ! empty ( $ requestHeaders ) ) { $ handle -> setOption ( CURLOPT_HTTPHEADER , $ this -> prepareHeaders ( $ requestHeaders ) ) ; } if ( $ returnResponseHeaders ) { $ handle -> setOption ( CURLOPT_HEADER , true ) ; } $ response = $ handle -> execute ( ) ; $ statusCode = $ handle -> getInfo ( CURLINFO_HTTP_CODE ) ; $ handle -> close ( ) ; if ( $ response && $ returnResponseHeaders ) { return $ this -> splitResponseHeaderAndBody ( $ response , $ statusCode ) ; } return $ response ; }
Executes a curl request while taking.

@param $url
@param array $requestHeaders
@param bool  $returnResponseHeaders

@return array|mixed
Executes a curl request while taking .