From 9d18408b49a4fcaec8e89612c984e76e280caa95 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 13 Apr 2020 11:02:03 +0200 Subject: [PATCH] http: doc deprecate abort and improve docs Doc deprecates ClientRequest.abort in favor of ClientRequest.destroy. Also improves event order documentation for abort and destroy. Refs: https://github.com/nodejs/node/issues/32225 PR-URL: https://github.com/nodejs/node/pull/32807 Reviewed-By: Matteo Collina Reviewed-By: Zeyu Yang Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Rich Trott --- doc/api/deprecations.md | 15 +++++++++ doc/api/http.md | 72 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 07e76f041ea2e1..acd951259621f2 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2569,6 +2569,19 @@ accordingly instead to avoid the ambigiuty. To maintain existing behaviour `response.finished` should be replaced with `response.writableEnded`. + +### DEP0XXX: Use `request.destroy()` instead of `request.abort()` + + +Type: Documentation-only + +Use [`request.destroy()`][] instead of [`request.abort()`][]. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`--throw-deprecation`]: cli.html#cli_throw_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size @@ -2627,8 +2640,10 @@ To maintain existing behaviour `response.finished` should be replaced with [`process.env`]: process.html#process_process_env [`punycode`]: punycode.html [`require.extensions`]: modules.html#modules_require_extensions +[`request.abort()`]: http.html#http_request_abort [`request.socket`]: http.html#http_request_socket [`request.connection`]: http.html#http_request_connection +[`request.destroy()`]: http.html#http_request_destroy_error [`response.socket`]: http.html#http_response_socket [`response.connection`]: http.html#http_response_connection [`response.end()`]: http.html#http_response_end_data_encoding_callback diff --git a/doc/api/http.md b/doc/api/http.md index a683eebdab5d26..7f097b0bc3a7f4 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -568,6 +568,7 @@ server.listen(1337, '127.0.0.1', () => { ### `request.abort()` Marks the request as aborting. Calling this will cause remaining data @@ -623,6 +624,31 @@ If `data` is specified, it is equivalent to calling If `callback` is specified, it will be called when the request stream is finished. +### `request.destroy([error])` + + +* `error` {Error} Optional, an error to emit with `'error'` event. +* Returns: {this} + +Destroy the request. Optionally emit an `'error'` event, +and emit a `'close'` event. Calling this will cause remaining data +in the response to be dropped and the socket to be destroyed. + +See [`writable.destroy()`][] for further details. + +#### `request.destroyed` + + +* {boolean} + +Is `true` after [`request.destroy()`][] has been called. + +See [`writable.destroyed`][] for further details. + ### `request.finished`