File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -636,10 +636,11 @@ OutgoingMessage.prototype._flush = function() {
636636
637637OutgoingMessage . prototype . flushHeaders = function ( ) {
638638 if ( ! this . _header ) {
639- // Force-flush the headers.
640639 this . _implicitHeader ( ) ;
641- this . _send ( '' ) ;
642640 }
641+
642+ // Force-flush the headers.
643+ this . _send ( '' ) ;
643644} ;
644645
645646OutgoingMessage . prototype . flush = util . deprecate ( function ( ) {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const http = require('http');
55
66const server = http . createServer ( ) ;
77server . on ( 'request' , function ( req , res ) {
8- assert ( req . headers [ 'foo' ] , 'bar' ) ;
8+ assert . equal ( req . headers [ 'foo' ] , 'bar' ) ;
99 res . end ( 'ok' ) ;
1010 server . close ( ) ;
1111} ) ;
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+
8+ server . on ( 'request' , function ( req , res ) {
9+ res . writeHead ( 200 , { 'foo' : 'bar' } ) ;
10+ res . flushHeaders ( ) ;
11+ res . flushHeaders ( ) ; // Should be idempotent.
12+ } ) ;
13+ server . listen ( common . PORT , common . localhostIPv4 , function ( ) {
14+ var req = http . request ( {
15+ method : 'GET' ,
16+ host : common . localhostIPv4 ,
17+ port : common . PORT ,
18+ } , onResponse ) ;
19+
20+ req . end ( ) ;
21+
22+ function onResponse ( res ) {
23+ assert . equal ( res . headers [ 'foo' ] , 'bar' ) ;
24+ res . destroy ( ) ;
25+ server . close ( ) ;
26+ }
27+ } ) ;
You can’t perform that action at this time.
0 commit comments