Express.js close response

后端 未结 2 1286
忘掉有多难
忘掉有多难 2020-12-01 23:23

Is there a way to close a response? I can use res.end() but it doesn\'t actually close the socket.

What I want to achieve: I am writing a Java program w

相关标签:
2条回答
  • 2020-12-02 00:02

    In case someone who really wants just to close the connection finds this, you can use res.socket or res.connection to get the net.Socket object which comes with a destroy method:

    res.connection.destroy();
    
    0 讨论(0)
  • 2020-12-02 00:07

    Solved by setting a HTTP header to close the connection instead of default keep-alive strategy.

    res.set("Connection", "close");
    
    0 讨论(0)
提交回复
热议问题