Merge branch 'connection-header'
This commit is contained in:
		
						commit
						ee3233ef5e
					
				@ -92,9 +92,18 @@ class RequestVerifier {
 | 
			
		||||
     * @return bool
 | 
			
		||||
     */
 | 
			
		||||
    public function verifyConnection(array $connectionHeader) {
 | 
			
		||||
        return count(array_filter($connectionHeader, function ($x) {
 | 
			
		||||
            return 'upgrade' === strtolower($x);
 | 
			
		||||
        })) > 0;
 | 
			
		||||
        foreach ($connectionHeader as $l) {
 | 
			
		||||
            $upgrades = array_filter(
 | 
			
		||||
                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,  ['Upgrade', 'keep-alive']),
 | 
			
		||||
            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, [])
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user