DEP0156: http 中的 .aborted 属性和 'abort'、'aborted' 事件


类型: 仅文档

改用 <Stream> API,因为 http.ClientRequesthttp.ServerResponsehttp.IncomingMessage 都是基于流的。 检查 stream.destroyed 而不是 .aborted 属性,并监听 'close' 而不是 'abort', 'aborted' 事件。

.aborted 属性和 'abort' 事件仅对检测 .abort() 调用有用。 如果要提前关闭请求,则使用流 .destroy([error]) 然后检查 .destroyed 属性和 'close' 事件应该具有相同的效果。 接收端还应该检查 http.IncomingMessage 上的 readable.readableEnded 值,以确定它是中止还是正常销毁。

Type: Documentation-only

Move to <Stream> API instead, as the http.ClientRequest, http.ServerResponse, and http.IncomingMessage are all stream-based. Check stream.destroyed instead of the .aborted property, and listen for 'close' instead of 'abort', 'aborted' event.

The .aborted property and 'abort' event are only useful for detecting .abort() calls. For closing a request early, use the Stream .destroy([error]) then check the .destroyed property and 'close' event should have the same effect. The receiving end should also check the readable.readableEnded value on http.IncomingMessage to get whether it was an aborted or graceful destroy.