private function _curlConnection($request)
    {
        // create a new curl resource
        $curl = curl_init();
        $method = $request->getRequestMethod();
        $headers = array('Expect:');

        // add existing headers into a flat string format
        foreach ($request->getHeaders() as $header) {
            $headers[] = rtrim($header->__toString());
        }

        // set URL and other appropriate options
        curl_setopt($curl, CURLOPT_URL, $request->getUrl());
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);
        curl_setopt($curl, CURLOPT_VERBOSE, false);
        curl_setopt($curl, CURLOPT_TIMEOUT_MS, $this->_timeout * 1000);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $this->_connectTimeoutMs);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_PROTOCOLS, (CURLPROTO_HTTP | CURLPROTO_HTTPS));
        curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, (CURLPROTO_HTTP | CURLPROTO_HTTPS));
        // Prevents issues with curl timing out much faster than the specified timeout
        curl_setopt($curl, CURLOPT_NOSIGNAL, 1);

        if (isset($this->_ipFamily)) {
            curl_setopt($curl, CURLOPT_IPRESOLVE, $this->_ipFamily);
        }

        // enable proxy support
        if (isset($this->_proxy)) {
            curl_setopt($curl, CURLOPT_PROXY, $this->_proxy);
        }

        // enable http authentication
        if (isset($this->_auth)) {
            curl_setopt($curl, CURLOPT_USERPWD, $this->_auth);
            curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        }

        if ($method == 'PUT' || $method == 'POST') {
            $headers[] = 'Content-Length: ' . strlen($request->getBody());

            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getBody());
        } elseif ($method == 'DELETE') {
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        }

        // add HTTP headers
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

        return $curl;
    }