Skip to content

Instantly share code, notes, and snippets.

@aoi0308
Created September 6, 2013 02:25
Show Gist options
  • Save aoi0308/6458800 to your computer and use it in GitHub Desktop.
Save aoi0308/6458800 to your computer and use it in GitHub Desktop.
Node 0.10.x でtobiが上手く動かないケース。 5回目のリダイレクトをする際に、なぜかリダイレクト後のリクエストを飛ばしてくれない。
/* 2013/09/06
* {
* "dependencies": {
* "tobi": "git://github.com/yssk22/tobi.git"
* },
* "engine": {
* "node": "0.10"
* }
* }
*/
var url = require('url');
var httpd = require('http').createServer(function(req, res) {
var pathname = url.parse(req.url).pathname;
console.log(pathname);
if (pathname == '/login') {
res.writeHead(302, {
location: '/login.html'
});
res.end();
} else {
res.setHeader('Content-Type', 'text/plain');
res.end('OK.');
}
});
httpd.listen(8888);
var tobi = require('tobi')
, browser = tobi.createBrowser(8888, 'localhost');
browser.get('/login', function(res, $) {
console.log($);
browser.get('/login', function(res, $) {
console.log($);
browser.get('/login', function(res, $) {
console.log($);
browser.get('/login', function(res, $) {
console.log($);
browser.get('/login', function(res, $) {
console.log($);
process.exit(0);
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment