Getting protocol from the URL in controller
You can use this in your controller :
$scheme = $this->getRequest()->getScheme();
Otherwise, here is a code allowing you to know all the values returned by the server:
foreach ($_SERVER as $key => $value) {
echo $key.' => '.$value.'<br>';
}
To check if request is https
use:
$request->isSecure()
Check doc for more info