@@ -2435,8 +2435,8 @@ added: v0.1.17
2435
2435
* Extends: {Stream}
2436
2436
2437
2437
This class serves as the parent class of [ ` http.ClientRequest ` ] [ ]
2438
- and [ ` http.ServerResponse ` ] [ ] . It is an abstract of outgoing message from
2439
- the perspective of the participants of HTTP transaction.
2438
+ and [ ` http.ServerResponse ` ] [ ] . It is an abstract outgoing message from
2439
+ the perspective of the participants of an HTTP transaction.
2440
2440
2441
2441
### Event: ` 'drain' `
2442
2442
@@ -2460,7 +2460,7 @@ Emitted when the transmission is finished successfully.
2460
2460
added: v0.11.6
2461
2461
-->
2462
2462
2463
- Emitted when ` outgoingMessage.end ` was called.
2463
+ Emitted after ` outgoingMessage.end() ` is called.
2464
2464
When the event is emitted, all data has been processed but not necessarily
2465
2465
completely flushed.
2466
2466
@@ -2474,11 +2474,11 @@ added: v0.3.0
2474
2474
2475
2475
Adds HTTP trailers (headers but at the end of the message) to the message.
2476
2476
2477
- Trailers are ** only** be emitted if the message is chunked encoded. If not,
2478
- the trailer will be silently discarded.
2477
+ Trailers will ** only** be emitted if the message is chunked encoded. If not,
2478
+ the trailers will be silently discarded.
2479
2479
2480
2480
HTTP requires the ` Trailer ` header to be sent to emit trailers,
2481
- with a list of header fields in its value, e.g.
2481
+ with a list of header field names in its value, e.g.
2482
2482
2483
2483
``` js
2484
2484
message .writeHead (200 , { ' Content-Type' : ' text/plain' ,
@@ -2502,7 +2502,7 @@ deprecated:
2502
2502
2503
2503
> Stability: 0 - Deprecated: Use [ ` outgoingMessage.socket ` ] [ ] instead.
2504
2504
2505
- Aliases of ` outgoingMessage.socket `
2505
+ Alias of [ ` outgoingMessage.socket ` ] [ ] .
2506
2506
2507
2507
### ` outgoingMessage.cork() `
2508
2508
@@ -2540,22 +2540,22 @@ changes:
2540
2540
2541
2541
Finishes the outgoing message. If any parts of the body are unsent, it will
2542
2542
flush them to the underlying system. If the message is chunked, it will
2543
- send the terminating chunk ` 0\r\n\r\n ` , and send the trailer (if any).
2543
+ send the terminating chunk ` 0\r\n\r\n ` , and send the trailers (if any).
2544
2544
2545
- If ` chunk ` is specified, it is equivalent to call
2545
+ If ` chunk ` is specified, it is equivalent to calling
2546
2546
` outgoingMessage.write(chunk, encoding) ` , followed by
2547
2547
` outgoingMessage.end(callback) ` .
2548
2548
2549
- If ` callback ` is provided, it will be called when the message is finished.
2550
- (equivalent to the callback to event ` finish ` )
2549
+ If ` callback ` is provided, it will be called when the message is finished
2550
+ (equivalent to a listener of the ` ' finish' ` event).
2551
2551
2552
2552
### ` outgoingMessage.flushHeaders() `
2553
2553
2554
2554
<!-- YAML
2555
2555
added: v1.6.0
2556
2556
-->
2557
2557
2558
- Compulsorily flushes the message headers
2558
+ Flushes the message headers.
2559
2559
2560
2560
For efficiency reason, Node.js normally buffers the message headers
2561
2561
until ` outgoingMessage.end() ` is called or the first chunk of message data
@@ -2564,7 +2564,7 @@ packet.
2564
2564
2565
2565
It is usually desired (it saves a TCP round-trip), but not when the first
2566
2566
data is not sent until possibly much later. ` outgoingMessage.flushHeaders() `
2567
- bypasses the optimization and kickstarts the request .
2567
+ bypasses the optimization and kickstarts the message .
2568
2568
2569
2569
### ` outgoingMessage.getHeader(name) `
2570
2570
@@ -2575,8 +2575,8 @@ added: v0.4.0
2575
2575
* ` name ` {string} Name of header
2576
2576
* Returns {string | undefined}
2577
2577
2578
- Gets the value of HTTP header with the given name. If such a name doesn't
2579
- exist in message, it will be ` undefined ` .
2578
+ Gets the value of the HTTP header with the given name. If that header is not
2579
+ set, the returned value will be ` undefined ` .
2580
2580
2581
2581
### ` outgoingMessage.getHeaderNames() `
2582
2582
@@ -2586,8 +2586,8 @@ added: v7.7.0
2586
2586
2587
2587
* Returns {string\[ ] }
2588
2588
2589
- Returns an array of names of headers of the outgoing outgoingMessage. All
2590
- names are lowercase.
2589
+ Returns an array containing the unique names of names of the current outgoing
2590
+ headers. All names are lowercase.
2591
2591
2592
2592
### ` outgoingMessage.getHeaders() `
2593
2593
@@ -2604,8 +2604,8 @@ object are the header names and the values are the respective header
2604
2604
values. All header names are lowercase.
2605
2605
2606
2606
The object returned by the ` outgoingMessage.getHeaders() ` method does
2607
- not prototypically inherit from the JavaScript Object. This means that
2608
- typical Object methods such as ` obj.toString() ` , ` obj.hasOwnProperty() ` ,
2607
+ not prototypically inherit from the JavaScript ` Object ` . This means that
2608
+ typical ` Object ` methods such as ` obj.toString() ` , ` obj.hasOwnProperty() ` ,
2609
2609
and others are not defined and will not work.
2610
2610
2611
2611
``` js
@@ -2648,14 +2648,11 @@ Read-only. `true` if the headers were sent, otherwise `false`.
2648
2648
added: v9.0.0
2649
2649
-->
2650
2650
2651
- Overrides the pipe method of legacy ` Stream ` which is the parent class of
2652
- ` http.outgoingMessage ` .
2651
+ Overrides the ` stream. pipe() ` method inherited from the legacy ` Stream ` class
2652
+ which is the parent class of ` http.OutgoingMessage ` .
2653
2653
2654
- Since ` OutgoingMessage ` should be a write-only stream,
2655
- call this function will throw an ` Error ` . Thus, it disabled the pipe method
2656
- it inherits from ` Stream ` .
2657
-
2658
- The User should not call this function directly.
2654
+ Calling this method will throw an ` Error ` because ` outgoingMessage ` is a
2655
+ write-only stream.
2659
2656
2660
2657
### ` outgoingMessage.removeHeader(name) `
2661
2658
@@ -2678,10 +2675,12 @@ added: v0.4.0
2678
2675
-->
2679
2676
2680
2677
* ` name ` {string} Header name
2681
- * ` value ` {string } Header value
2678
+ * ` value ` {any } Header value
2682
2679
* Returns: {this}
2683
2680
2684
- Sets a single header value for the header object.
2681
+ Sets a single header value. If the header already exists in the to-be-sent
2682
+ headers, its value will be replaced. Use an array of strings to send multiple
2683
+ headers with the same name.
2685
2684
2686
2685
### ` outgoingMessage.setTimeout(msesc[, callback]) `
2687
2686
@@ -2726,8 +2725,7 @@ added: v14.0.0
2726
2725
2727
2726
* {number}
2728
2727
2729
- This ` outgoingMessage.writableCorked ` will return the time how many
2730
- ` outgoingMessage.cork() ` have been called.
2728
+ The number of times ` outgoingMessage.cork() ` has been called.
2731
2729
2732
2730
### ` outgoingMessage.writableEnded `
2733
2731
@@ -2737,9 +2735,9 @@ added: v13.0.0
2737
2735
2738
2736
* {boolean}
2739
2737
2740
- Readonly, ` true ` if ` outgoingMessage.end() ` has been called. Noted that
2741
- this property does not reflect whether the data has been flush . For that
2742
- purpose, use ` message.writableFinished ` instead.
2738
+ Is ` true ` if ` outgoingMessage.end() ` has been called. This property does
2739
+ not indicate whether the data has been flushed . For that purpose, use
2740
+ ` message.writableFinished ` instead.
2743
2741
2744
2742
### ` outgoingMessage.writableFinished `
2745
2743
@@ -2749,7 +2747,7 @@ added: v13.0.0
2749
2747
2750
2748
* {boolean}
2751
2749
2752
- Readonly. ` true ` if all data has been flushed to the underlying system.
2750
+ Is ` true ` if all data has been flushed to the underlying system.
2753
2751
2754
2752
### ` outgoingMessage.writableHighWaterMark `
2755
2753
@@ -2759,12 +2757,8 @@ added: v13.0.0
2759
2757
2760
2758
* {number}
2761
2759
2762
- This ` outgoingMessage.writableHighWaterMark ` will be the ` highWaterMark ` of
2763
- underlying socket if socket exists. Else, it would be the default
2764
- ` highWaterMark ` .
2765
-
2766
- ` highWaterMark ` is the maximum amount of data that can be potentially
2767
- buffered by the socket.
2760
+ The ` highWaterMark ` of the underlying socket if assigned. Otherwise, the default
2761
+ buffer level when [ ` writable.write() ` ] [ ] starts returning false (` 16384 ` ).
2768
2762
2769
2763
### ` outgoingMessage.writableLength `
2770
2764
@@ -2774,8 +2768,7 @@ added: v13.0.0
2774
2768
2775
2769
* {number}
2776
2770
2777
- Readonly, This ` outgoingMessage.writableLength ` contains the number of
2778
- bytes (or objects) in the buffer ready to send.
2771
+ The number of buffered bytes.
2779
2772
2780
2773
### ` outgoingMessage.writableObjectMode `
2781
2774
@@ -2785,51 +2778,33 @@ added: v13.0.0
2785
2778
2786
2779
* {boolean}
2787
2780
2788
- Readonly, always returns ` false ` .
2781
+ Always ` false ` .
2789
2782
2790
2783
### ` outgoingMessage.write(chunk[, encoding][, callback]) `
2791
2784
2792
2785
<!-- YAML
2793
2786
added: v0.1.29
2794
2787
changes:
2795
2788
- version: v0.11.6
2796
- description: add `callback` argument.
2789
+ description: The `callback` argument was added .
2797
2790
-->
2798
2791
2799
2792
* ` chunk ` {string | Buffer}
2800
2793
* ` encoding ` {string} ** Default** : ` utf8 `
2801
2794
* ` callback ` {Function}
2802
2795
* Returns {boolean}
2803
2796
2804
- If this method is called and the header is not sent, it will call
2805
- ` this._implicitHeader ` to flush implicit header.
2806
- If the message should not have a body (indicated by ` this._hasBody ` ),
2807
- the call is ignored and ` chunk ` will not be sent. It could be useful
2808
- when handling a particular message which must not include a body.
2809
- e.g. response to ` HEAD ` request, ` 204 ` and ` 304 ` response.
2810
-
2811
- ` chunk ` can be a string or a buffer. When ` chunk ` is a string, the
2812
- ` encoding ` parameter specifies how to encode ` chunk ` into a byte stream.
2813
- ` callback ` will be called when the ` chunk ` is flushed.
2797
+ Sends a chunk of the body. This method can be called multiple times.
2814
2798
2815
- If the message is transferred in chucked encoding
2816
- (indicated by ` this.chunkedEncoding ` ), ` chunk ` will be flushed as
2817
- one chunk among a stream of chunks. Otherwise, it will be flushed as the
2818
- body of message.
2799
+ The ` encoding ` argument is only relevant when ` chunk ` is a string. Defaults to
2800
+ ` 'utf8' ` .
2819
2801
2820
- This method handles the raw body of the HTTP message and has nothing to do
2821
- with higher-level multi-part body encodings that may be used.
2822
-
2823
- If it is the first call to this method of a message, it will send the
2824
- buffered header first, then flush the ` chunk ` as described above.
2825
-
2826
- The second and successive calls to this method will assume the data
2827
- will be streamed and send the new data separately. It means that the response
2828
- is buffered up to the first chunk of the body.
2802
+ The ` callback ` argument is optional and will be called when this chunk of data
2803
+ is flushed.
2829
2804
2830
2805
Returns ` true ` if the entire data was flushed successfully to the kernel
2831
2806
buffer. Returns ` false ` if all or part of the data was queued in the user
2832
- memory. Event ` drain ` will be emitted when the buffer is free again.
2807
+ memory. The ` ' drain' ` event will be emitted when the buffer is free again.
2833
2808
2834
2809
## ` http.METHODS `
2835
2810
@@ -3515,5 +3490,6 @@ try {
3515
3490
[ `writable.cork()` ] : stream.md#writablecork
3516
3491
[ `writable.destroy()` ] : stream.md#writabledestroyerror
3517
3492
[ `writable.destroyed` ] : stream.md#writabledestroyed
3493
+ [ `writable.write()` ] : stream.md#writablewritechunk-encoding-callback
3518
3494
[ `writable.uncork()` ] : stream.md#writableuncork
3519
3495
[ initial delay ] : net.md#socketsetkeepaliveenable-initialdelay
0 commit comments