Skip to content

Commit 6adcc6f

Browse files
ronagBridgeAR
authored andcommitted
http2: Http2ServerResponse.end() should always return self
PR-URL: #24346 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 275a8f9 commit 6adcc6f

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎lib/internal/http2/compat.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ class Http2ServerResponse extends Stream {
648648

649649
if((state.closed||state.ending)&&
650650
state.headRequest===stream.headRequest){
651-
returnfalse;
651+
returnthis;
652652
}
653653

654654
if(typeofchunk==='function'){

‎test/parallel/test-http2-compat-serverresponse-end.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,34 @@ const {
6060
}));
6161
}
6262

63+
{
64+
// Http2ServerResponse.end should return self after end
65+
constserver=createServer(mustCall((request,response)=>{
66+
strictEqual(response,response.end());
67+
strictEqual(response,response.end());
68+
server.close();
69+
}));
70+
server.listen(0,mustCall(()=>{
71+
const{ port }=server.address();
72+
consturl=`http://localhost:${port}`;
73+
constclient=connect(url,mustCall(()=>{
74+
constheaders={
75+
':path': '/',
76+
':method': 'GET',
77+
':scheme': 'http',
78+
':authority': `localhost:${port}`
79+
};
80+
constrequest=client.request(headers);
81+
request.setEncoding('utf8');
82+
request.on('end',mustCall(()=>{
83+
client.close();
84+
}));
85+
request.end();
86+
request.resume();
87+
}));
88+
}));
89+
}
90+
6391
{
6492
// Http2ServerResponse.end can omit encoding arg, sets it to utf-8
6593
constserver=createServer(mustCall((request,response)=>{

0 commit comments

Comments
 (0)