Skip to content

Instantly share code, notes, and snippets.

@narqo
Created March 19, 2013 19:51
Show Gist options
  • Save narqo/5199497 to your computer and use it in GitHub Desktop.
Save narqo/5199497 to your computer and use it in GitHub Desktop.
Тестовый обработчик POST-запроса в Node.js
› node htttest.js && curl -d "user=someone" --url http://127.0.0.1:4001
require('http')
.createServer(function(req, res) {
req.setEncoding('utf8');
process.nextTick(function() {
req.on('data', console.log.bind(null, '+')); // Несработает в Node.js < 0.10.x — promise'ы идут лесом :_(
});
req.on('end', function() {
res.end('DONE!!!');
});
})
.listen(4001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment