http: don't slice unless necessary
The incoming Buffer was being sliced just to possibly not be used. Instead place the .slice inside the conditional to not be created unless necessary.
This commit is contained in:
parent
f0d80d7db0
commit
88333f7ace
@ -352,11 +352,10 @@ function connectionListener(socket) {
|
||||
parser.finish();
|
||||
freeParser(parser, req);
|
||||
|
||||
// This is start + byteParsed
|
||||
var bodyHead = d.slice(start + bytesParsed, end);
|
||||
|
||||
var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
|
||||
if (EventEmitter.listenerCount(self, eventName) > 0) {
|
||||
// This is start + byteParsed
|
||||
var bodyHead = d.slice(start + bytesParsed, end);
|
||||
self.emit(eventName, req, req.socket, bodyHead);
|
||||
} else {
|
||||
// Got upgrade header or CONNECT method, but have no handler.
|
||||
|
Loading…
x
Reference in New Issue
Block a user