Skip to content

Commit 6dbd63c

Browse files
ronagcodebytere
authored andcommitted
Revert "http: set IncomingMessage.destroyed"
This reverts commit 28e6626. PR-URL: #33686 Backport-PR-URL: #33686 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent feb6e1f commit 6dbd63c

10 files changed

Lines changed: 4 additions & 93 deletions

‎lib/_http_client.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,10 @@ function socketCloseListener() {
426426
req.emit('close');
427427
if(!res.aborted&&res.readable){
428428
res.on('end',function(){
429-
this.destroyed=true;
430429
this.emit('close');
431430
});
432431
res.push(null);
433432
}else{
434-
res.destroyed=true;
435433
res.emit('close');
436434
}
437435
}else{
@@ -545,7 +543,6 @@ function socketOnData(d) {
545543
socket.readableFlowing=null;
546544

547545
req.emit(eventName,res,socket,bodyHead);
548-
req.destroyed=true;
549546
req.emit('close');
550547
}else{
551548
// Requested Upgrade or used CONNECT method, but have no handler.

‎lib/_http_incoming.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ IncomingMessage.prototype._read = function _read(n) {
119119
// any messages, before ever calling this. In that case, just skip
120120
// it, since something else is destroying this connection anyway.
121121
IncomingMessage.prototype.destroy=functiondestroy(error){
122-
// TODO(ronag): Implement in terms of _destroy
123-
this.destroyed=true;
124122
if(this.socket)
125123
this.socket.destroy(error);
126124
returnthis;

‎lib/_http_server.js‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ function onServerResponseClose() {
205205
// Ergo, we need to deal with stale 'close' events and handle the case
206206
// where the ServerResponse object has already been deconstructed.
207207
// Fortunately, that requires only a single if check. :-)
208-
if(this._httpMessage){
209-
this._httpMessage.destroyed=true;
210-
this._httpMessage.emit('close');
211-
}
208+
if(this._httpMessage)this._httpMessage.emit('close');
212209
}
213210

214211
ServerResponse.prototype.assignSocket=functionassignSocket(socket){
@@ -537,7 +534,6 @@ function abortIncoming(incoming) {
537534
while(incoming.length){
538535
constreq=incoming.shift();
539536
req.aborted=true;
540-
req.destroyed=true;
541537
req.emit('aborted');
542538
req.emit('close');
543539
}
@@ -664,13 +660,11 @@ function clearIncoming(req) {
664660
if(parser&&parser.incoming===req){
665661
if(req.readableEnded){
666662
parser.incoming=null;
667-
req.destroyed=true;
668663
req.emit('close');
669664
}else{
670665
req.on('end',clearIncoming);
671666
}
672667
}else{
673-
req.destroyed=true;
674668
req.emit('close');
675669
}
676670
}
@@ -714,7 +708,6 @@ function resOnFinish(req, res, socket, state, server) {
714708
}
715709

716710
functionemitCloseNT(self){
717-
self.destroyed=true;
718711
self.emit('close');
719712
}
720713

‎test/parallel/test-http-client-res-destroyed.js‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎test/parallel/test-http-connect-req-res.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ server.listen(0, common.mustCall(function() {
3333
path: 'example.com:443'
3434
},common.mustNotCall());
3535

36-
assert.strictEqual(req.destroyed,false);
37-
req.on('close',common.mustCall(()=>{
38-
assert.strictEqual(req.destroyed,true);
39-
}));
36+
req.on('close',common.mustCall());
4037

4138
req.on('connect',common.mustCall(function(res,socket,firstBodyChunk){
4239
console.error('Client got CONNECT request');

‎test/parallel/test-http-connect.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ server.listen(0, common.mustCall(() => {
6262
assert.strictEqual(socket._httpMessage,req);
6363
}));
6464

65-
assert.strictEqual(req.destroyed,false);
66-
req.on('close',common.mustCall(()=>{
67-
assert.strictEqual(req.destroyed,true);
68-
}));
65+
req.on('close',common.mustCall());
6966

7067
req.on('connect',common.mustCall((res,socket,firstBodyChunk)=>{
7168
// Make sure this request got removed from the pool.

‎test/parallel/test-http-pause-resume-one-end.js‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'use strict';
2323
constcommon=require('../common');
2424
consthttp=require('http');
25-
constassert=require('assert');
2625

2726
constserver=http.Server(function(req,res){
2827
res.writeHead(200,{'Content-Type': 'text/plain'});
@@ -44,12 +43,6 @@ server.listen(0, common.mustCall(function() {
4443
});
4544
}));
4645

47-
res.on('end',common.mustCall(()=>{
48-
assert.strictEqual(res.destroyed,false);
49-
}));
50-
assert.strictEqual(res.destroyed,false);
51-
res.on('close',common.mustCall(()=>{
52-
assert.strictEqual(res.destroyed,true);
53-
}));
46+
res.on('end',common.mustCall());
5447
}));
5548
}));

‎test/parallel/test-http-req-res-close.js‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,13 @@ const server = http.Server(common.mustCall((req, res) => {
88
letresClosed=false;
99

1010
res.end();
11-
letresFinished=false;
1211
res.on('finish',common.mustCall(()=>{
13-
resFinished=true;
14-
assert.strictEqual(resClosed,false);
15-
assert.strictEqual(res.destroyed,false);
1612
assert.strictEqual(resClosed,false);
1713
}));
18-
assert.strictEqual(req.destroyed,false);
1914
res.on('close',common.mustCall(()=>{
2015
resClosed=true;
21-
assert.strictEqual(resFinished,true);
22-
assert.strictEqual(res.destroyed,true);
23-
}));
24-
assert.strictEqual(req.destroyed,false);
25-
req.on('end',common.mustCall(()=>{
26-
assert.strictEqual(req.destroyed,false);
2716
}));
2817
req.on('close',common.mustCall(()=>{
29-
assert.strictEqual(req.destroyed,true);
3018
assert.strictEqual(req._readableState.ended,true);
3119
}));
3220
res.socket.on('close',()=>server.close());

‎test/parallel/test-http-response-close.js‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
'use strict';
2323
constcommon=require('../common');
2424
consthttp=require('http');
25-
constassert=require('assert');
2625

2726
{
2827
constserver=http.createServer(
@@ -40,9 +39,7 @@ const assert = require('assert');
4039
res.on('data',common.mustCall(()=>{
4140
res.destroy();
4241
}));
43-
assert.strictEqual(res.destroyed,false);
4442
res.on('close',common.mustCall(()=>{
45-
assert.strictEqual(res.destroyed,true);
4643
server.close();
4744
}));
4845
})
@@ -64,12 +61,7 @@ const assert = require('assert');
6461
http.get(
6562
{port: server.address().port},
6663
common.mustCall((res)=>{
67-
assert.strictEqual(res.destroyed,false);
68-
res.on('end',common.mustCall(()=>{
69-
assert.strictEqual(res.destroyed,false);
70-
}));
7164
res.on('close',common.mustCall(()=>{
72-
assert.strictEqual(res.destroyed,true);
7365
server.close();
7466
}));
7567
res.resume();

‎test/parallel/test-http-server-stale-close.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
require('../common');
2424
consthttp=require('http');
2525
constfork=require('child_process').fork;
26-
constassert=require('assert');
2726

2827
if(process.env.NODE_TEST_FORK_PORT){
2928
constreq=http.request({
@@ -38,9 +37,7 @@ if (process.env.NODE_TEST_FORK_PORT) {
3837
constserver=http.createServer((req,res)=>{
3938
res.writeHead(200,{'Content-Length': '42'});
4039
req.pipe(res);
41-
assert.strictEqual(req.destroyed,false);
4240
req.on('close',()=>{
43-
assert.strictEqual(req.destroyed,true);
4441
server.close();
4542
res.end();
4643
});

0 commit comments

Comments
 (0)