function PageCacheTest::getHeaders
Retrieves only the headers for an absolute path.
Executes a cURL request without any modifications to the given URL. Note that Guzzle always normalizes URLs which prevents testing all possible edge cases.
Parameters
string $url: URL to request.
Return value
array Array of headers.
File
- 
              core/modules/ hal/ tests/ src/ Functional/ page_cache/ PageCacheTest.php, line 111 
Class
- PageCacheTest
- Enables the page cache and tests it with various HTTP requests.
Namespace
Drupal\Tests\hal\Functional\page_cacheCode
protected function getHeaders($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HEADER, TRUE);
  curl_setopt($ch, CURLOPT_NOBODY, TRUE);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_USERAGENT, drupal_generate_test_ua($this->databasePrefix));
  $output = curl_exec($ch);
  curl_close($ch);
  $headers = [];
  foreach (explode("\n", $output) as $header) {
    if (strpos($header, ':')) {
      [$key, $value] = explode(':', $header, 2);
      $headers[trim($key)] = trim($value);
    }
  }
  return $headers;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
