[WebSocket] RFC Protocol Compliance
Refs #13 Fixed AB tests: 2.5, 4.* RFC fails connections on bad control frames
This commit is contained in:
parent
ed83f67a84
commit
653d8fb482
@ -93,27 +93,19 @@ class RFC6455 implements VersionInterface {
|
||||
$frame = $from->WebSocket->frame;
|
||||
|
||||
if (!$frame->isMasked()) {
|
||||
unset($from->WebSocket->frame);
|
||||
|
||||
$from->send($this->newFrame($frame::CLOSE_PROTOCOL, true, $frame::OP_CLOSE));
|
||||
$from->getConnection()->close();
|
||||
|
||||
return;
|
||||
return $from->close($frame::CLOSE_PROTOCOL);
|
||||
}
|
||||
|
||||
$opcode = $frame->getOpcode();
|
||||
|
||||
if ($opcode > 2) {
|
||||
if ($frame->getPayloadLength() > 125) {
|
||||
return $from->close($frame::CLOSE_PROTOCOL);
|
||||
}
|
||||
|
||||
switch ($opcode) {
|
||||
case $frame::OP_CLOSE:
|
||||
$from->close($frame->getPayload());
|
||||
/*
|
||||
$from->send($frame->unMaskPayload());
|
||||
$from->getConnection()->close();
|
||||
*/
|
||||
// $from->send(Frame::create(Frame::CLOSE_NORMAL, true, Frame::OP_CLOSE));
|
||||
|
||||
return;
|
||||
return $from->close($frame);
|
||||
break;
|
||||
case $frame::OP_PING:
|
||||
$from->send($this->newFrame($frame->getPayload(), true, $frame::OP_PONG));
|
||||
|
@ -20,7 +20,11 @@ class Connection extends AbstractConnectionDecorator {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close($code = 1000) {
|
||||
$this->send(new Frame($code, true, Frame::OP_CLOSE));
|
||||
if ($code instanceof DataInterface) {
|
||||
$this->send($code);
|
||||
} else {
|
||||
$this->send(new Frame(Frame::encode(sprintf('%016b', $code)), true, Frame::OP_CLOSE));
|
||||
}
|
||||
|
||||
$this->getConnection()->close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user