Created
February 26, 2015 18:37
-
-
Save aronatkins/df6c4174778d14851aa7 to your computer and use it in GitHub Desktop.
A simple HTTP server that echoes all incoming requests to stdout and replies with HTTP 200 OK.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var port = process.argv[2] || 8888; | |
http.createServer(function(request,response){ | |
console.log('request start'); | |
console.log(request.method, request.url, request.httpVersion); | |
console.log('headers',request.headers); | |
request.on('data',function(chunk){ | |
process.stdout.write(chunk.toString()); | |
}); | |
request.on('end',function(){ | |
response.writeHead(200); | |
response.end(); | |
console.log('request end'); | |
}); | |
}).listen(port, function() { | |
console.log('listening on',port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment