No Mask on Frame
HyBi spec says server shouldn't mask payloads when delivering to client - now allow user to specify to mask or not; WebSocket by default will not mask, Framing on its own will
This commit is contained in:
parent
4de9caaa78
commit
e6012d1685
@ -39,6 +39,8 @@ class App implements ApplicationInterface, ConfiguratorInterface {
|
||||
, 'Hixie76' => null
|
||||
);
|
||||
|
||||
protected $_mask_payload = false;
|
||||
|
||||
public function __construct(ApplicationInterface $app = null) {
|
||||
if (null === $app) {
|
||||
throw new \UnexpectedValueException("WebSocket requires an application to run");
|
||||
@ -171,7 +173,7 @@ class App implements ApplicationInterface, ConfiguratorInterface {
|
||||
}
|
||||
|
||||
$version = $command->getConnection()->WebSocket->version;
|
||||
return $command->setMessage($version->frame($command->getMessage()));
|
||||
return $command->setMessage($version->frame($command->getMessage(), $this->_mask_payload));
|
||||
}
|
||||
|
||||
if ($command instanceof \Traversable) {
|
||||
@ -226,4 +228,14 @@ class App implements ApplicationInterface, ConfiguratorInterface {
|
||||
|
||||
unset($this->_versions[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the option to mask the payload upon sending to client
|
||||
* If WebSocket is used as server, this should be false, client to true
|
||||
* @param bool
|
||||
* @todo User shouldn't have to know/set this, need to figure out how to do this automatically
|
||||
*/
|
||||
public function setMaskPayload($opt) {
|
||||
$this->_mask_payload = (boolean)$opt;
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class Hixie76 implements VersionInterface {
|
||||
return new Hixie76\Frame;
|
||||
}
|
||||
|
||||
public function frame($message) {
|
||||
public function frame($message, $mask = true) {
|
||||
return chr(0) . $message . chr(255);
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,10 @@ class HyBi10 implements VersionInterface {
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function frame($message) {
|
||||
public function frame($message, $mask = true) {
|
||||
$payload = $message;
|
||||
$type = 'text';
|
||||
$masked = true;
|
||||
$masked = $mask;
|
||||
|
||||
$frameHead = array();
|
||||
$frame = '';
|
||||
|
@ -35,8 +35,9 @@ interface VersionInterface {
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
* @todo Change to use other classes, this will be removed eventually
|
||||
*/
|
||||
function frame($message);
|
||||
function frame($message, $mask = true);
|
||||
}
|
Loading…
Reference in New Issue
Block a user