protected function prepareRequest(Request $request)
    {
        $curl = curl_init();
        
        // TODO Timeout and Follow Redirect settings
        $options = array(
            CURLOPT_RETURNTRANSFER    => true,
            CURLOPT_HEADER            => true,
            CURLOPT_CONNECTTIMEOUT_MS => 1000,
            CURLOPT_TIMEOUT_MS        => 3000,
            CURLOPT_CUSTOMREQUEST     => $request->getMethod(),
            CURLOPT_URL               => $request->getUri(),
            CURLOPT_HTTPHEADER        => $request->getHeaders(),
            CURLOPT_HTTPGET           => false,
            CURLOPT_NOBODY            => false,
            CURLOPT_POST              => false,
            CURLOPT_POSTFIELDS        => null,           
        );

        switch ($request->getMethod()) {
            case Request::METHOD_HEAD:
                $options[CURLOPT_NOBODY] = true;
                
                $query = http_build_query($request->getParameters());
                if (!empty($query)) {
                    $options[CURLOPT_URL] = $request->getUri().'?'.$query;
                }
                break;

            case Request::METHOD_GET:
                $options[CURLOPT_HTTPGET] = true;
                
                $query = http_build_query($request->getParameters());
                if (!empty($query)) {
                    $options[CURLOPT_URL] = $request->getUri().'?'.$query;
                }
                break;

            case Request::METHOD_POST:
            case Request::METHOD_PUT:
                $options[CURLOPT_POST] = true;
                $options[CURLOPT_POSTFIELDS] = http_build_query($request->getParameters());
                break;
        }
        
        curl_setopt_array($curl, $options);
        
        return $curl;
    }