public function DomainValidator::checkResponse in Domain Access 8
Tests that a domain responds correctly.
This is a server-level configuration test. The core module provides an image file that we use to test the validity of domain-generated URLs.
That file is /domain/tests/200.png.
Parameters
\Drupal\domain\DomainInterface $domain: A domain record.
Return value
int The server response code for the request.
Overrides DomainValidatorInterface::checkResponse
File
- domain/src/ DomainValidator.php, line 127 
Class
- DomainValidator
- Provides validation of domain strings against RFC standards for hostnames.
Namespace
Drupal\domainCode
public function checkResponse(DomainInterface $domain) {
  $url = $domain
    ->getPath() . drupal_get_path('module', 'domain') . '/tests/200.png';
  try {
    // GuzzleHttp no longer allows for bogus URL calls.
    $request = $this->httpClient
      ->get($url);
  } catch (RequestException $e) {
    // File a general server failure.
    $domain
      ->setResponse(500);
    return $domain
      ->getResponse();
  }
  // Expected result (i.e. no exception thrown.)
  $domain
    ->setResponse($request
    ->getStatusCode());
  return $domain
    ->getResponse();
}