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
array $filteredHeaders Array of special headers:
array $actualHeaders Array of headers to check against:
array|bool Returns an array of the differences or FALSE if none
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);
}