Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
Closed
Changes from all commits
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: 6 additions & 2 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,9 @@ function socketOnData(d, start, end) {
parser.finish();

// This is start + byteParsed
var bodyHead = d.slice(start + bytesParsed, end);
//Apps that hang on to bodyHead can lead to large slab buffer retention
var bodyHead = new Buffer(end - start - bytesParsed);
d.copy(bodyHead,0,start + bytesParsed, end);

var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
if (req.listeners(eventName).length) {
Expand Down Expand Up @@ -1834,7 +1836,9 @@ function connectionListener(socket) {
freeParser(parser, req);

// This is start + byteParsed
var bodyHead = d.slice(start + bytesParsed, end);
//Apps that hang on to bodyHead can lead to large slab buffer retention
var bodyHead = new Buffer(end - start - bytesParsed);
d.copy(bodyHead,0,start + bytesParsed, end);

var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
if (self.listeners(eventName).length) {
Expand Down