outgoingMessage.flushHeaders()


刷新消息标头。

【Flushes the message headers.】

出于效率考虑,Node.js 通常会缓存消息头,直到调用 outgoingMessage.end() 或写入消息数据的第一个片段。然后,它会尝试将头部和数据打包到一个 TCP 数据包中。

【For efficiency reason, Node.js normally buffers the message headers until outgoingMessage.end() is called or the first chunk of message data is written. It then tries to pack the headers and data into a single TCP packet.】

通常这是希望的(可以节省一次 TCP 往返),但当第一次数据可能要很久之后才发送时就不适用。outgoingMessage.flushHeaders() 会绕过这个优化并启动消息发送。

【It is usually desired (it saves a TCP round-trip), but not when the first data is not sent until possibly much later. outgoingMessage.flushHeaders() bypasses the optimization and kickstarts the message.】