File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -866,7 +866,7 @@ the client should send the request body.
866
866
Emitted when the request has been aborted by the client. This event is only
867
867
emitted on the first call to ` abort() ` .
868
868
869
- ### request.flush ()
869
+ ### request.flushHeaders ()
870
870
871
871
Flush the request headers.
872
872
@@ -875,7 +875,7 @@ call `request.end()` or write the first chunk of request data. It then tries
875
875
hard to pack the request headers and data into a single TCP packet.
876
876
877
877
That's usually what you want (it saves a TCP round-trip) but not when the first
878
- data isn't sent until possibly much later. ` request.flush () ` lets you bypass
878
+ data isn't sent until possibly much later. ` request.flushHeaders () ` lets you bypass
879
879
the optimization and kickstart the request.
880
880
881
881
### request.write(chunk[ , encoding] [ , callback ] )
Original file line number Diff line number Diff line change @@ -630,10 +630,14 @@ OutgoingMessage.prototype._flush = function() {
630
630
} ;
631
631
632
632
633
- OutgoingMessage . prototype . flush = function ( ) {
633
+ OutgoingMessage . prototype . flushHeaders = function ( ) {
634
634
if ( ! this . _header ) {
635
635
// Force-flush the headers.
636
636
this . _implicitHeader ( ) ;
637
637
this . _send ( '' ) ;
638
638
}
639
639
} ;
640
+
641
+ OutgoingMessage . prototype . flush = util . deprecate ( function ( ) {
642
+ this . flushHeaders ( ) ;
643
+ } , 'flush is deprecated. Use flushHeaders instead.' ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const http = require ( 'http' ) ;
5
+
6
+ const server = http . createServer ( ) ;
7
+ server . on ( 'request' , function ( req , res ) {
8
+ assert ( req . headers [ 'foo' ] , 'bar' ) ;
9
+ res . end ( 'ok' ) ;
10
+ server . close ( ) ;
11
+ } ) ;
12
+ server . listen ( common . PORT , '127.0.0.1' , function ( ) {
13
+ let req = http . request ( {
14
+ method : 'GET' ,
15
+ host : '127.0.0.1' ,
16
+ port : common . PORT ,
17
+ } ) ;
18
+ req . setHeader ( 'foo' , 'bar' ) ;
19
+ req . flushHeaders ( ) ;
20
+ } ) ;
You can’t perform that action at this time.
0 commit comments