You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var http = require('http');
var through = require('through');
var server = http.createServer(function (req, res) {
if (req.method === 'POST') {
req.pipe(through(function (buf) {
this.queue(buf.toString().toUpperCase());
})).pipe(res);
}
else res.end('send me a POST\n');
});
server.listen(parseInt(process.argv[2]));
which could pass the http server task. but if I separate the through function like:
var tr = through(write).. like the following code.
var http = require('http');
var through = require('through');
var tr = through(function (buf) {
this.queue(buf.toString().toUpperCase());
});
var server = http.createServer(function (req, res) {
if (req.method === 'POST') {
req.pipe(tr).pipe(res);
}
else res.end('send me a POST\n');
});
server.listen(parseInt(process.argv[2]));
The official answer is
which could pass the http server task. but if I separate the through function like:
var tr = through(write).. like the following code.
It failed, give me the error like:
Could anybody tell me why?
The text was updated successfully, but these errors were encountered: