@@ -568,6 +568,7 @@ server.listen(1337, '127.0.0.1', () => {
568
568
### ` request.abort() `
569
569
<!-- YAML
570
570
added: v0.3.8
571
+ deprecated: REPLACEME
571
572
-->
572
573
573
574
Marks the request as aborting. Calling this will cause remaining data
@@ -623,6 +624,31 @@ If `data` is specified, it is equivalent to calling
623
624
If ` callback ` is specified, it will be called when the request stream
624
625
is finished.
625
626
627
+ ### ` request.destroy([error]) `
628
+ <!-- YAML
629
+ added: v0.3.0
630
+ -->
631
+
632
+ * ` error ` {Error} Optional, an error to emit with ` 'error' ` event.
633
+ * Returns: {this}
634
+
635
+ Destroy the request. Optionally emit an ` 'error' ` event,
636
+ and emit a ` 'close' ` event. Calling this will cause remaining data
637
+ in the response to be dropped and the socket to be destroyed.
638
+
639
+ See [ ` writable.destroy() ` ] [ ] for further details.
640
+
641
+ #### ` request.destroyed `
642
+ <!-- YAML
643
+ added: REPLACEME
644
+ -->
645
+
646
+ * {boolean}
647
+
648
+ Is ` true ` after [ ` request.destroy() ` ] [ ] has been called.
649
+
650
+ See [ ` writable.destroyed ` ] [ ] for further details.
651
+
626
652
### ` request.finished `
627
653
<!-- YAML
628
654
added: v0.0.1
@@ -2354,8 +2380,43 @@ the following events will be emitted in the following order:
2354
2380
* ` 'close' `
2355
2381
* ` 'close' ` on the ` res ` object
2356
2382
2357
- If ` req.abort() ` is called before the connection succeeds, the following events
2358
- will be emitted in the following order:
2383
+ If ` req.destroy() ` is called before a socket is assigned, the following
2384
+ events will be emitted in the following order:
2385
+
2386
+ * (` req.destroy() ` called here)
2387
+ * ` 'error' ` with an error with message ` 'Error: socket hang up' ` and code
2388
+ ` 'ECONNRESET' `
2389
+ * ` 'close' `
2390
+
2391
+ If ` req.destroy() ` is called before the connection succeeds, the following
2392
+ events will be emitted in the following order:
2393
+
2394
+ * ` 'socket' `
2395
+ * (` req.destroy() ` called here)
2396
+ * ` 'error' ` with an error with message ` 'Error: socket hang up' ` and code
2397
+ ` 'ECONNRESET' `
2398
+ * ` 'close' `
2399
+
2400
+ If ` req.destroy() ` is called after the response is received, the following
2401
+ events will be emitted in the following order:
2402
+
2403
+ * ` 'socket' `
2404
+ * ` 'response' `
2405
+ * ` 'data' ` any number of times, on the ` res ` object
2406
+ * (` req.destroy() ` called here)
2407
+ * ` 'aborted' ` on the ` res ` object
2408
+ * ` 'close' `
2409
+ * ` 'close' ` on the ` res ` object
2410
+
2411
+ If ` req.abort() ` is called before a socket is assigned, the following
2412
+ events will be emitted in the following order:
2413
+
2414
+ * (` req.abort() ` called here)
2415
+ * ` 'abort' `
2416
+ * ` 'close' `
2417
+
2418
+ If ` req.abort() ` is called before the connection succeeds, the following
2419
+ events will be emitted in the following order:
2359
2420
2360
2421
* ` 'socket' `
2361
2422
* (` req.abort() ` called here)
@@ -2364,8 +2425,8 @@ will be emitted in the following order:
2364
2425
` 'ECONNRESET' `
2365
2426
* ` 'close' `
2366
2427
2367
- If ` req.abort() ` is called after the response is received, the following events
2368
- will be emitted in the following order:
2428
+ If ` req.abort() ` is called after the response is received, the following
2429
+ events will be emitted in the following order:
2369
2430
2370
2431
* ` 'socket' `
2371
2432
* ` 'response' `
@@ -2411,6 +2472,7 @@ not abort the request or do anything besides add a `'timeout'` event.
2411
2472
[ `new URL()` ] : url.html#url_constructor_new_url_input_base
2412
2473
[ `removeHeader(name)` ] : #http_request_removeheader_name
2413
2474
[ `request.end()` ] : #http_request_end_data_encoding_callback
2475
+ [ `request.destroy()` ] : #http_request_destroy_error
2414
2476
[ `request.flushHeaders()` ] : #http_request_flushheaders
2415
2477
[ `request.getHeader()` ] : #http_request_getheader_name
2416
2478
[ `request.setHeader()` ] : #http_request_setheader_name_value
@@ -2440,5 +2502,7 @@ not abort the request or do anything besides add a `'timeout'` event.
2440
2502
[ `socket.unref()` ] : net.html#net_socket_unref
2441
2503
[ `url.parse()` ] : url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
2442
2504
[ `HPE_HEADER_OVERFLOW` ] : errors.html#errors_hpe_header_overflow
2505
+ [ `writable.destroy()` ] : stream.html#stream_writable_destroy_error
2506
+ [ `writable.destroyed` ] : stream.html#stream_writable_destroyed
2443
2507
[ `writable.cork()` ] : stream.html#stream_writable_cork
2444
2508
[ `writable.uncork()` ] : stream.html#stream_writable_uncork
0 commit comments