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


【DEP0156: .aborted property and 'abort', 'aborted' event in http

类型:仅文档

【Type: Documentation-only】

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

【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.】

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

【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.】