public static function Securepages::isHTTPSSupported in Secure Pages 8
Perform an HTTPS test with the request of the test page is necessary.
Return value
bool TRUE if HTTPS is supposed, FALSE otherwise.
1 call to Securepages::isHTTPSSupported()
- SecurepagesSettingsForm::buildForm in src/
Form/ SecurepagesSettingsForm.php - Form constructor.
File
- src/
Securepages.php, line 186 - Contains \Drupal\securepages\Securepages.
Class
- Securepages
- Utility class for global functionality.
Namespace
Drupal\securepagesCode
public static function isHTTPSSupported() {
// If this request was already HTTPS, it is supported.
if (\Drupal::requestStack()
->getCurrentRequest()
->isSecure()) {
return TRUE;
}
// Otherwise, attempt to load the test page with HTTPS.
/** @var \GuzzleHttp\Client $client */
try {
$client = \Drupal::httpClient();
$response = $client
->request('GET', Securepages::getUrl('<front>')
->toString(), [
'verify' => FALSE,
]);
return $response
->getStatusCode() === 200;
} catch (RequestException $e) {
return FALSE;
}
}