/**
  * @param \Ratchet\ConnectionInterface $context
  * @param string                       $data    Data stream to buffer
  *
  * @return \Guzzle\Http\Message\RequestInterface|null
  *
  * @throws \OverflowException If the message buffer has become too large
  */
 public function onMessage(ConnectionInterface $context, $data)
 {
     if (!isset($context->httpBuffer)) {
         $context->httpBuffer = '';
     }
     $context->httpBuffer .= $data;
     if (strlen($context->httpBuffer) > (int) $this->maxSize) {
         throw new \OverflowException("Maximum buffer size of {$this->maxSize} exceeded parsing HTTP header");
     }
     if ($this->isEom($context->httpBuffer)) {
         $request = RequestFactory::getInstance()->fromMessage($context->httpBuffer);
         unset($context->httpBuffer);
         return $request;
     }
 }
Esempio n. 2
0
 public function setUp()
 {
     $this->factory = RequestFactory::getInstance();
 }