File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 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.
866866Emitted when the request has been aborted by the client. This event is only
867867emitted on the first call to ` abort() ` .
868868
869- ### request.flush ()
869+ ### request.flushHeaders ()
870870
871871Flush the request headers.
872872
@@ -875,7 +875,7 @@ call `request.end()` or write the first chunk of request data. It then tries
875875hard to pack the request headers and data into a single TCP packet.
876876
877877That'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
879879the optimization and kickstart the request.
880880
881881### request.write(chunk[ , encoding] [ , callback ] )
Original file line number Diff line number Diff line change @@ -630,10 +630,14 @@ OutgoingMessage.prototype._flush = function() {
630630} ;
631631
632632
633- OutgoingMessage . prototype . flush = function ( ) {
633+ OutgoingMessage . prototype . flushHeaders = function ( ) {
634634 if ( ! this . _header ) {
635635 // Force-flush the headers.
636636 this . _implicitHeader ( ) ;
637637 this . _send ( '' ) ;
638638 }
639639} ;
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