Skip to content

Instantly share code, notes, and snippets.

@axpwx
Forked from polotek/node_redir_test.js
Created November 13, 2012 20:59
Show Gist options
  • Select an option

  • Save axpwx/4068354 to your computer and use it in GitHub Desktop.

Select an option

Save axpwx/4068354 to your computer and use it in GitHub Desktop.
Testing 301 redirects with node
var http = require('http');
var server = http.createServer(function (req, resp) {
if(req.url.match('redir')) {
resp.writeHead(301, {'Location':'http://google.com/', 'Expires': (new Date).toGMTString()});
resp.end();
} else {
resp.writeHead(200, {'content-type': 'text/plain', 'content-length':4});
resp.end('Main');
}
});
server.listen(8081);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment