在node.js Express中删除请求 [英] Drop request in node.js express
本文介绍了在node.js Express中删除请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用Node.js和express放弃对某些路由的请求? IE.不返回http状态或任何标题?我只想关闭连接.
Is it possible using Node.js and express to drop a request for certain route? I.E. not return a http status or any headers? I'd like to just close the connection.
app.get('/drop', function(req, res) {
//how to drop the request here
});
推荐答案
要关闭连接而不返回任何内容,您可以 destroy()
基础套接字.
To close a connection without returning anything, you can either end()
or destroy()
the underlying socket.
app.get('/drop', function(req, res) {
req.socket.end();
});
我认为没有任何办法可以在您端断开连接,但是要让客户端等待直到超时(即不发送FIN
).您可能必须以某种方式与防火墙进行交互.
I don't think there's any way to drop the connection at your end but keep the client waiting until it times out (i.e. without sending a FIN
). You'd perhaps have to interact with your firewall in some way.
这篇关于在node.js Express中删除请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文