所以我想执行多个请求-但是我必须能够在启动下一个请求后立即停止上一个请求。
基本上,我希望能够在下一个请求管道准备就绪时清除每个请求管道。
var http = require('http'),
request = require('request');
var server = http.createServer(function onRequest(req, res) {
router(req, res, finalhandler(req, res))
})
remoteUrl = "http://s3.yesstreaming.net:7062/stream";
const aq = request.get(remoteUrl);
aq.on('response', (response) => {
response.pause();
// Do stuff with response.statusCode etc.
setTimeout(() => {
response
.pipe(res)
;
const aq = request.get('http://stream.radiomedia.com.au:8003/stream');
aq.on('response', (response) => {
response.pause();
// Do stuff with response.statusCode etc.
setTimeout(() => {
response
.pipe(res);
},8000);
});
}, 3000);
});
server.listen(8080)