Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,13 @@ function connectionListener(socket) {
exports._connectionListener = connectionListener;

function onSocketResume() {
this._handle.readStart();
if (this._handle)
this._handle.readStart();
}

function onSocketPause() {
this._handle.readStop();
if (this._handle)
this._handle.readStop();
}

function socketOnWrap(ev, fn) {
Expand All @@ -526,7 +528,7 @@ function socketOnWrap(ev, fn) {
return res;
}

if (ev === 'data' || ev === 'readable')
if (this._handle && (ev === 'data' || ev === 'readable'))
this.parser.unconsume(this._handle._externalStream);

return res;
Expand Down
23 changes: 23 additions & 0 deletions test/parallel/test-http-regr-gh-2821.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');

const server = http.createServer(function(req, res) {
res.writeHead(200);
res.end();

server.close();
});

server.listen(common.PORT, function() {

const req = http.request({
method: 'POST',
port: common.PORT
});

const payload = new Array(1640).join('0123456789');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo a new Buffer(16384).fill(0) would be better here. Or with some other value that was causing this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, fixed.

req.write(payload);
req.end();
});