function prepare_http_request ($mnet_peer) {
        $this->uri = $mnet_peer->wwwroot . $mnet_peer->application->xmlrpc_server_url;

        // Initialize request the target URL
        $httprequest = curl_init($this->uri);
        curl_setopt($httprequest, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($httprequest, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($httprequest, CURLOPT_POST, true);
        curl_setopt($httprequest, CURLOPT_USERAGENT, 'Moodle');
        curl_setopt($httprequest, CURLOPT_HTTPHEADER, array("Content-Type: text/xml charset=UTF-8"));

        $verifyhost = 0;
        $verifypeer = false;
        if ($mnet_peer->sslverification == mnet_peer::SSL_HOST_AND_PEER) {
            $verifyhost = 2;
            $verifypeer = true;
        } else if ($mnet_peer->sslverification == mnet_peer::SSL_HOST) {
            $verifyhost = 2;
        }
        curl_setopt($httprequest, CURLOPT_SSL_VERIFYHOST, $verifyhost);
        curl_setopt($httprequest, CURLOPT_SSL_VERIFYPEER, $verifypeer);
        return $httprequest;
    }