public function HeaderComparison::compare

Compare HTTP headers and use special markup to filter values A header prefixed with '!' means it must not exist A header prefixed with '_' means it must be ignored A header value of '*' means anything after the * will be ignored

Parameters

array $filteredHeaders Array of special headers:

array $actualHeaders Array of headers to check against:

Return value

array|bool Returns an array of the differences or FALSE if none

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/HeaderComparison.php, line 23

Class

HeaderComparison
Class used to compare HTTP headers using a custom DSL

Namespace

Guzzle\Http\Message

Code

public function compare($filteredHeaders, $actualHeaders) {
  $expected = array();
  $ignore = array();
  $absent = array();
  if ($actualHeaders instanceof Collection) {
    $actualHeaders = $actualHeaders
      ->getAll();
  }
  foreach ($filteredHeaders as $k => $v) {
    if ($k[0] == '_') {

      // This header should be ignored
      $ignore[] = str_replace('_', '', $k);
    }
    elseif ($k[0] == '!') {

      // This header must not be present
      $absent[] = str_replace('!', '', $k);
    }
    else {
      $expected[$k] = $v;
    }
  }
  return $this
    ->compareArray($expected, $actualHeaders, $ignore, $absent);
}