Merge branch 'connection-header'
This commit is contained in:
commit
ee3233ef5e
@ -92,9 +92,18 @@ class RequestVerifier {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function verifyConnection(array $connectionHeader) {
|
public function verifyConnection(array $connectionHeader) {
|
||||||
return count(array_filter($connectionHeader, function ($x) {
|
foreach ($connectionHeader as $l) {
|
||||||
return 'upgrade' === strtolower($x);
|
$upgrades = array_filter(
|
||||||
})) > 0;
|
array_map('trim', array_map('strtolower', explode(',', $l))),
|
||||||
|
function ($x) {
|
||||||
|
return 'upgrade' === $x;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (count($upgrades) > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,6 +113,11 @@ class RequestVerifierTest extends \PHPUnit_Framework_TestCase {
|
|||||||
array(true, ['keep-alive', 'Upgrade']),
|
array(true, ['keep-alive', 'Upgrade']),
|
||||||
array(true, ['Upgrade', 'keep-alive']),
|
array(true, ['Upgrade', 'keep-alive']),
|
||||||
array(true, ['keep-alive', 'Upgrade', 'something']),
|
array(true, ['keep-alive', 'Upgrade', 'something']),
|
||||||
|
// as seen in Firefox 47.0.1 - see https://github.com/ratchetphp/RFC6455/issues/14
|
||||||
|
array(true, ['keep-alive, Upgrade']),
|
||||||
|
array(true, ['Upgrade, keep-alive']),
|
||||||
|
array(true, ['keep-alive, Upgrade, something']),
|
||||||
|
array(true, ['keep-alive, Upgrade', 'something']),
|
||||||
array(false, ['']),
|
array(false, ['']),
|
||||||
array(false, [])
|
array(false, [])
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user