diff --git a/lib/caronte/passes/ws.js b/lib/caronte/passes/ws.js index d89f752..a99277f 100644 --- a/lib/caronte/passes/ws.js +++ b/lib/caronte/passes/ws.js @@ -20,10 +20,12 @@ var passes = exports; */ function checkMethodAndHeader (req, res, options) { - if (req.method !== 'GET' || req.headers.upgrade.toLowerCase() !== 'websocket') { - req.end(); - - return true; + if (req.method !== 'GET' || !req.headers.upgrade) { + req.end(); return true; + } + + if (req.headers.upgrade.toLowerCase() !== 'websocket') { + req.end(); return true; } }, diff --git a/lib/caronte/streams/proxy.js b/lib/caronte/streams/proxy.js index 2f93987..29c2fa7 100644 --- a/lib/caronte/streams/proxy.js +++ b/lib/caronte/streams/proxy.js @@ -3,6 +3,8 @@ var Duplex = require('stream').Duplex, http = require('http'), https = require('https'); +module.exports = ProxyStream; + function ProxyStream(options, res) { Duplex.call(this); @@ -100,5 +102,3 @@ ProxyStream.prototype._read = function(size) { this.push(chunk); }; - -module.exports = ProxyStream; diff --git a/lib/caronte/streams/websocket.js b/lib/caronte/streams/websocket.js index 3f073ab..dc43daf 100644 --- a/lib/caronte/streams/websocket.js +++ b/lib/caronte/streams/websocket.js @@ -1,8 +1,10 @@ var Duplex = require('stream').Duplex, - common = require('common'), + common = require('../common'), http = require('http'), https = require('https'); +module.exports = WebsocketStream; + function WebsocketStream(options, res) { Duplex.call(this); @@ -34,7 +36,7 @@ WebsocketStream.prototype.onPipe = function(req) { }); }; -WebsocketStream.prototye.onFinish = function() { +WebsocketStream.prototype.onFinish = function() { this.proxyReq.end(); }; @@ -55,7 +57,4 @@ WebsocketStream.prototype._write = function(chunk, encoding, callback) { WebsocketStream.prototype._read = function(size) { -}; - - -WebsocketStream.prototype +}; \ No newline at end of file