跳到主要内容
CNode

express response写stream怎么写?

问答
Wwizali发布于 10 年前最后回复 10 年前
289440

我现在处理一个支付成功的回调,对方要求回写一段stream,请问Express的response怎么写呢?

查看回复

回复 (2)

V
vendetta0114#210 年前

app.get('/stream',function(req,res){ res.setHeader('Content-Type', 'text/event-stream'); res.setHeader('Cache-Control', 'no-cache'); var cc = setInterval(function(){ res.write('something'); res.flush(); },1000); res.on('close',function(){ clearInterval(cc); }); })

M
meteormatt#110 年前

参与回复

登录后即可参与回复。登录