mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user