Ugly Hacks
Added some ugly hacks to fix Hixie: * Hixie now should work no matter how small the I/O buffer is * Hixie now works with the Guzzle library*
This commit is contained in:
parent
a1c6ee163f
commit
83f49f1f55
@ -18,6 +18,8 @@ use Guzzle\Http\Message\RequestFactory;
|
||||
* @todo Consider chaning this class to a State Pattern. If a WS App interface is passed use different state for additional methods used
|
||||
*/
|
||||
class App implements ApplicationInterface, ConfiguratorInterface {
|
||||
const CRLF = "\r\n\r\n";
|
||||
|
||||
/**
|
||||
* Decorated application
|
||||
* @var Ratchet\Application\ApplicationInterface
|
||||
@ -87,6 +89,7 @@ class App implements ApplicationInterface, ConfiguratorInterface {
|
||||
}
|
||||
|
||||
$headers = RequestFactory::fromMessage($from->WebSocket->headers);
|
||||
$headers->setHeader('X-Body', $this->getBody($from->WebSocket->headers));
|
||||
$from->WebSocket->version = $this->getVersion($headers);
|
||||
$from->WebSocket->headers = $headers;
|
||||
}
|
||||
@ -236,10 +239,32 @@ class App implements ApplicationInterface, ConfiguratorInterface {
|
||||
/**
|
||||
* @param string
|
||||
* @return bool
|
||||
* @todo Method is flawed, this CAN result in an error with the Hixie protocol
|
||||
* @todo Abstract, some hard coding done for (stupid) Hixie protocol
|
||||
*/
|
||||
protected function isMessageComplete($message) {
|
||||
return (boolean)strstr($message, "\r\n\r\n");
|
||||
$headers = (boolean)strstr($message, static::CRLF);
|
||||
if (!$headers) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strstr($message, 'Sec-WebSocket-Key2')) {
|
||||
if (8 !== strlen($this->getBody($message))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return string
|
||||
* @deprecated
|
||||
* @todo Remove soon, this is a temp hack for Hixie
|
||||
*/
|
||||
protected function getBody($message) {
|
||||
return substr($message, strpos($message, static::CRLF) + strlen(static::CRLF));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ class Hixie76 implements VersionInterface {
|
||||
* @return string
|
||||
*/
|
||||
public function handshake(RequestInterface $request) {
|
||||
$message = $request->getRawHeaders() . $request->getResponse()->getBody(true);
|
||||
$message = $request->getRawHeaders() . "\r\n\r\n" . $request->getHeader('X-Body');
|
||||
|
||||
$buffer = $message;
|
||||
$resource = $host = $origin = $key1 = $key2 = $protocol = $code = $handshake = null;
|
||||
|
Loading…
Reference in New Issue
Block a user