Files
nginx-unit/test/node/promise_handler/app.js
Valentin Bartenev 7fd9444728 Node.js: returning "this" from writeHead() to allow chaining.
In Node.js version 11.10.0 and later, the writeHead() function returns "this".
2019-08-06 16:24:11 +03:00

18 lines
408 B
JavaScript
Executable File

#!/usr/bin/env node
var fs = require('fs');
require('unit-http').createServer(function (req, res) {
res.end();
if (req.headers['x-write-call']) {
res.writeHead(200, {'Content-Type': 'text/plain'}).write('blah');
}
Promise.resolve().then(() => {
req.on('data', (data) => {
fs.appendFile(data.toString(), '', function() {});
});
});
}).listen(7080);