api/MarkLogic/MLPHP/RESTClient.php
protected function execute(&$ch)
    {
        $response = new RESTResponse();
        $curl_exec = curl_exec($ch);
        // print('******* START $curl_exec (body) *******' . PHP_EOL);
        // print_r($curl_exec);
        // print('******* END   $curl_exec (body) *******' . PHP_EOL);
        $response->setBody($curl_exec);
        $curl_getinfo = curl_getinfo($ch);
        // print('******* START $curl_getinfo *******' . PHP_EOL);
        // print_r($curl_getinfo);
        // print('******* END   $curl_getinfo *******' . PHP_EOL);
        $response->setInfo($curl_getinfo);
        //print_r($response);
        $this->logger->debug("Response code: " . $response->getHttpCode());
        if ($response->getHttpCode() === 0) {
            curl_close ($ch);
            throw new \Exception(
              'No connection: ' . $response->getUrl(),
              $response->getHttpCode()
            );
        } else if ($response->getHttpCode() >= 400) {
            curl_close ($ch);
            $this->logger->debug("HTTP Error " . $response->getHttpCode());
            throw new \Exception(
              $response->getErrorMessage(),
              $response->getHttpCode()
            );
        } else {
            curl_close ($ch);
            // print('***** RESPONSE *****' . PHP_EOL);
            // print_r($response);
            return $response;
        }
    }
protected function execute(&$ch)
    {
        $response = new RESTResponse();
        $curl_exec = curl_exec($ch);
        // print('******* START $curl_exec (body) *******' . PHP_EOL);
        // print_r($curl_exec);
        // print('******* END   $curl_exec (body) *******' . PHP_EOL);
        $response->setBody($curl_exec);
        $curl_getinfo = curl_getinfo($ch);
        // print('******* START $curl_getinfo *******' . PHP_EOL);
        // print_r($curl_getinfo);
        // print('******* END   $curl_getinfo *******' . PHP_EOL);
        $response->setInfo($curl_getinfo);
        //print_r($response);
        $this->logger->debug("Response code: " . $response->getHttpCode());
        if ($response->getHttpCode() === 0) {
            curl_close ($ch);
            throw new \Exception(
              'No connection: ' . $response->getUrl(),
              $response->getHttpCode()
            );
        } else if ($response->getHttpCode() >= 400) {
            curl_close ($ch);
            $this->logger->debug("HTTP Error " . $response->getHttpCode());
            throw new \Exception(
              $response->getErrorMessage(),
              $response->getHttpCode()
            );
        } else {
            curl_close ($ch);
            // print('***** RESPONSE *****' . PHP_EOL);
            // print_r($response);
            return $response;
        }
    }
Execute a cURL request.

@todo Handle more response codes

@param resource ch The REST URL string (example: 'documents')
@return RESTResponse A RESTResponse object.