From f8abda0d5f068a2e727ee5d17ff30289b44eec3c Mon Sep 17 00:00:00 2001 From: Vasily Zorin Date: Thu, 7 Apr 2016 10:51:50 +0000 Subject: [PATCH] Added 'websocket' SockJS method which returns 426 Upgrade Required --- PHPDaemon/Servers/WebSocket/Connection.php | 2 +- PHPDaemon/SockJS/Methods/Websocket.php | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 PHPDaemon/SockJS/Methods/Websocket.php diff --git a/PHPDaemon/Servers/WebSocket/Connection.php b/PHPDaemon/Servers/WebSocket/Connection.php index 914b2316..d39dc6bc 100644 --- a/PHPDaemon/Servers/WebSocket/Connection.php +++ b/PHPDaemon/Servers/WebSocket/Connection.php @@ -393,7 +393,7 @@ protected function httpProcessHeaders() { if (!isset($this->server['HTTP_CONNECTION']) || (!preg_match('~(?:^|\W)Upgrade(?:\W|$)~i', $this->server['HTTP_CONNECTION'])) // "Upgrade" is not always alone (ie. "Connection: Keep-alive, Upgrade") || !isset($this->server['HTTP_UPGRADE']) - || (strtolower($this->server['HTTP_UPGRADE']) !== 'websocket') // Lowercase compare important + || (strtolower($this->server['HTTP_UPGRADE']) !== 'websocket') // Lowercase comparison iss important ) { $this->finish(); return false; diff --git a/PHPDaemon/SockJS/Methods/Websocket.php b/PHPDaemon/SockJS/Methods/Websocket.php new file mode 100644 index 00000000..877d7452 --- /dev/null +++ b/PHPDaemon/SockJS/Methods/Websocket.php @@ -0,0 +1,30 @@ + + */ +class Websocket extends Generic { + protected $contentType = 'text/plain'; + + /** + * Constructor + * @return void + */ + public function init() { + $this->header('426 Upgrade Required'); + $this->finish(); + } + + /** + * Called when request iterated + * @return void + */ + public function run() {} +}