Skip to content

Instantly share code, notes, and snippets.

@bnoguchi
Created July 21, 2011 02:32
Show Gist options
  • Save bnoguchi/1096393 to your computer and use it in GitHub Desktop.
Save bnoguchi/1096393 to your computer and use it in GitHub Desktop.
Gist for connect-zip Issue GH-2
var assert = require('assert'),
express = require('express'),
gzip = require('connect-gzip');
var app = express.createServer();
app.set('view engine', 'jade');
app.use(gzip.gzip());
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({secret: 'xxx',}));
var name = 1;
app.get('/', function(req, res) {
var sess = req.session;
sess.name || (sess.name = name++);
console.log(req.session);
// res.redirect('http://google.com/');
res.writeHead(303, { 'Location': 'http://google.com/' });
res.end();
});
app.get('/two', function (req, res) {
var sess = req.session;
sess.name || (sess.name = name++);
console.log(req.session);
assert.equal(sess.name, 1);
res.render('main', {layout: false});
});
app.listen(3000);
{
"author": "",
"name": "GH-273",
"version": "0.0.0",
"repository": {
"url": ""
},
"engines": {
"node": ">=v0.4.0"
},
"dependencies": {
"connect-gzip": ">=0.0.0",
"express": ">=0.0.0",
"jade": ">=0.0.0"
},
"devDependencies": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment