Test before redirect

I need to test if a ssl server is likely to respond before doing any forward as I would otherwise “loose” a projection screen.
As the server uses only a self-signed certificate, basically all javascript tricks (iframe on the fly, jsonp, …) failed either due to Cross-Origin Resource Sharing (CORS) rules. Even after switching to php the first two methods failed (get header, fsockets) while I finally ended with a simple curl request

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://localhost:8443');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
if (curl_error($ch)[0]=="") header('Location: https://localhost:8443');