Created
November 29, 2010 15:07
-
-
Save lerouxb/720050 to your computer and use it in GitHub Desktop.
Log all posted variables via a little nodejs server.
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'), | |
querystring = require('querystring') | |
var PORT = 8124; | |
http.createServer(function(req, res) { | |
if (req.method == 'POST') { | |
req.rawpostdata = ''; | |
req.addListener('data', function(chunk) { | |
req.rawpostdata += chunk.toString('ascii'); // I hope | |
}); | |
req.addListener('end', function() { | |
req.formdata = querystring.parse(req.rawpostdata); | |
var body = '====================\n'; | |
for (var k in req.formdata) { | |
body += k+'='+req.formdata[k]+'\n'; | |
} | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end(body); | |
console.log(body); | |
}); | |
} else { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Not a POST request.'); | |
} | |
}).listen(PORT); | |
console.log('Server running at http://127.0.0.1:/'+PORT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment