Skip to content

Commit

Permalink
Parse the cookies and add them to the req when building up a simulate…
Browse files Browse the repository at this point in the history
…d express context.
  • Loading branch information
Curtis Lacy committed May 22, 2013
1 parent 43884ea commit e80cb79
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/router/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Load routes config
var _ = require('underscore');
var Router = require('./index');
var cookie = require( 'cookie' );


// Set readable and writable in constructor.
Expand Down Expand Up @@ -72,7 +73,7 @@ exports.route = function(socketReq, fn, socket) {

// Interpret a socket.io request to express js semantics
exports.interpret = function(socketIOData, socketIOCallback, socket) {

// Build request object
var req = exports.req = {
_socketIOPretender: true,
Expand Down Expand Up @@ -100,8 +101,12 @@ exports.interpret = function(socketIOData, socketIOCallback, socket) {
listen: function (room) {
return this.socket.join(room);
}

};

if( socket.handshake.headers.cookie )
req.cookie = cookie.parse( socket.handshake.headers.cookie );

// Provide easy access to host (Express 3.x)
req.host = req.headers['host'];

Expand Down

0 comments on commit e80cb79

Please sign in to comment.