[WebSockets] Handshake encoding + case insensitivity

Updated RFC6455 handshaker to check values case insensitively
Made sure RFC6455 handshaker matches encoding properly
Added mbstring as a requirement for Ratchet
Refs #28, #30
This commit is contained in:
Chris Boden 2012-05-19 23:36:32 -04:00
parent b9144b3b82
commit 1be159f9fa
2 changed files with 8 additions and 12 deletions

View File

@ -2,12 +2,6 @@
namespace Ratchet\WebSocket\Version;
interface FrameInterface {
/**
* Dunno if I'll use this
* Thinking could be used if a control frame?
*/
// function __invoke();
/**
* @return bool
*/

View File

@ -32,10 +32,9 @@ class HandshakeVerifier {
* Test the HTTP method. MUST be "GET"
* @param string
* @return bool
* @todo Look into STD if "get" is valid (am I supposed to do case conversion?)
*/
public function verifyMethod($val) {
return ('GET' === $val);
return ('get' === mb_strtolower($val, 'ASCII'));
}
/**
@ -50,7 +49,6 @@ class HandshakeVerifier {
/**
* @param string
* @return bool
* @todo Verify the logic here is correct
*/
public function verifyRequestURI($val) {
if ($val[0] != '/') {
@ -80,7 +78,7 @@ class HandshakeVerifier {
* @return bool
*/
public function verifyUpgradeRequest($val) {
return ('websocket' === $val);
return ('websocket' === mb_strtolower($val, 'ASCII'));
}
/**
@ -89,12 +87,16 @@ class HandshakeVerifier {
* @return bool
*/
public function verifyConnection($val) {
if ('Upgrade' === $val) {
$val = mb_strtolower($val, 'ASCII');
if ('upgrade' === $val) {
return true;
}
// todo change this to mb_eregi_replace
$vals = explode(',', str_replace(', ', ',', $val));
return (false !== array_search('Upgrade', $vals));
return (false !== array_search('upgrade', $vals));
}
/**