[WebSocket] Re-scoped variable
Protecting Frame::$data to prevent overflow error Correct frame contents is fetched from ::getContents()
This commit is contained in:
parent
305865a938
commit
412f5c2d07
@ -177,7 +177,7 @@ class RFC6455 implements VersionInterface {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function frame($message, $mask = true) {
|
public function frame($message, $mask = true) {
|
||||||
return $this->newFrame($message)->data;
|
return $this->newFrame($message)->getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,23 +14,18 @@ class Connection extends AbstractConnectionDecorator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function send($msg) {
|
public function send($msg) {
|
||||||
if ($msg instanceof FrameInterface) {
|
if (!($msg instanceof FrameInterface)) {
|
||||||
$data = $msg->data;
|
$msg = new Frame($msg);
|
||||||
} else {
|
|
||||||
$frame = new Frame($msg);
|
|
||||||
$data = $frame->data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getConnection()->send($data);
|
$this->getConnection()->send($msg->getContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function close($code = 1000) {
|
public function close($code = 1000) {
|
||||||
$frame = new Frame($code, true, Frame::OP_CLOSE);
|
$this->send(new Frame($code, true, Frame::OP_CLOSE));
|
||||||
|
|
||||||
$this->send($frame->data);
|
|
||||||
|
|
||||||
$this->getConnection()->close();
|
$this->getConnection()->close();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class Frame implements FrameInterface {
|
|||||||
* The contents of the frame
|
* The contents of the frame
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $data = '';
|
protected $data = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of bytes received from the frame
|
* Number of bytes received from the frame
|
||||||
@ -367,6 +367,14 @@ class Frame implements FrameInterface {
|
|||||||
return $payload;
|
return $payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the raw contents of the frame
|
||||||
|
* @todo This is untested, make sure the substr is right - trying to return the frame w/o the overflow
|
||||||
|
*/
|
||||||
|
public function getContents() {
|
||||||
|
return substr($this->data, 0, $this->getPayloadStartingByte() + $this->getPayloadLength());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sometimes clients will concatinate more than one frame over the wire
|
* Sometimes clients will concatinate more than one frame over the wire
|
||||||
* This method will take the extra bytes off the end and return them
|
* This method will take the extra bytes off the end and return them
|
||||||
|
Loading…
Reference in New Issue
Block a user