Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Let the user intercept HTTP Upgrade requests in addition to normal HT…

…TP requests. This is useful for checking cookies as a means for deciding if the (WebSocket) connection should be permitted.
  • Loading branch information...
commit f50fc81110a6d97ceaa6a2ca8094f3aa983ee8ce 1 parent 046c7a3
@mscdex authored
Showing with 7 additions and 1 deletion.
  1. +2 −0  deps/cookie-node.js
  2. +5 −1 lib/grappler.js
View
2  deps/cookie-node.js
@@ -37,6 +37,8 @@ processCookie = exports.processCookie = function(name, value) {
var mutateHttp = function(http){
+ if (http.IncomingMessage.prototype._parseCookies)
+ return;
http.IncomingMessage.prototype._parseCookies = function() {
var header = this.headers["cookie"] || "",
View
6 lib/grappler.js
@@ -215,7 +215,11 @@ function Server(options/*, fnHandleNormalHTTP, fnAcceptClient*/) {
req.connection.removeAllListeners('timeout');
req.connection.removeAllListeners('data');
- new HttpClient(req, socket, head);
+ // Let grappler handle this request if it wasn't already handled by the callback
+ if (!cbHandleHTTP(req, socket))
+ new HttpClient(req, socket, head);
+ else
+ logger('Server :: HTTP Upgrade request handled by callback. id == ' + req.connection.client.id, LOG.INFO);
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.