request.flushHeaders()


刷新请求头。

【Flushes the request headers.】

出于效率原因,Node.js 通常会缓冲请求头,直到调用 request.end() 或写入请求数据的第一块时。然后它会尝试将请求头和数据打包到一个 TCP 数据包中。

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

这通常是理想的(它可以节省一次 TCP 往返),但当第一次数据可能很晚才发送时就不适用了。request.flushHeaders() 可以绕过这种优化并启动请求。

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