api/MarkLogic/MLPHP/RESTClient.php
protected function setOptions(&$ch, $urlStr, $headers)
    {
        $url = $this->prefix . $urlStr; // Build full URL
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPAUTH, $this->auth);
        curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);

        curl_setopt($ch, CURLINFO_HEADER_OUT, true); // For debugging; TODO otherwise disable

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // Expose ?
        curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Expose ?

        $headerArr = array();
        foreach ($headers as $key => $val) {
            $headerArr[] = $key . ':' . $val;
        }
        // If headers exist, add them
        if (count($headerArr) > 0) {
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr);
        }

    }
protected function setOptions(&$ch, $urlStr, $headers)
    {
        $url = $this->prefix . $urlStr; // Build full URL
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPAUTH, $this->auth);
        curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);

        curl_setopt($ch, CURLINFO_HEADER_OUT, true); // For debugging; TODO otherwise disable

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // Expose ?
        curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Expose ?

        $headerArr = array();
        foreach ($headers as $key => $val) {
            $headerArr[] = $key . ':' . $val;
        }
        // If headers exist, add them
        if (count($headerArr) > 0) {
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr);
        }

    }
Set cURL options common to all requests

@param resource ch The cURL handle.
@param string url The REST URL string (example: 'documents').
@param array headers Optional assoc array of headers.
@return array An array of cURL options.