Skip to content

Commit

Permalink
Added 'websocket' SockJS method which returns 426 Upgrade Required
Browse files Browse the repository at this point in the history
  • Loading branch information
kakserpom committed Apr 7, 2016
1 parent 029d323 commit f8abda0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PHPDaemon/Servers/WebSocket/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 30 additions & 0 deletions PHPDaemon/SockJS/Methods/Websocket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
namespace PHPDaemon\SockJS\Methods;

use PHPDaemon\Core\Daemon;
use PHPDaemon\Core\Debug;
use PHPDaemon\Utils\Crypt;

/**
* @package Libraries
* @subpackage SockJS
* @author Vasily Zorin <[email protected]>
*/
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() {}
}

0 comments on commit f8abda0

Please sign in to comment.