Skip to content

Commit 3763dc9

Browse files
committed
Merge pull request #370 from jmatthewsr-ms/master
Fix for slab buffer retention, leading to large memory consumption
2 parents 71183bf + d2888c8 commit 3763dc9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/node-http-proxy/http-proxy.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,15 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
439439
// Performs a WebSocket proxy operation to the location specified by
440440
// `this.target`.
441441
//
442-
HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer) {
442+
HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead, buffer) {
443443
var self = this,
444444
outgoing = new(this.target.base),
445445
listeners = {},
446446
errState = false,
447-
CRLF = '\r\n';
447+
CRLF = '\r\n',
448+
//copy upgradeHead to avoid retention of large slab buffers used in node core
449+
head = new Buffer(upgradeHead.length);
450+
upgradeHead.copy(head);
448451

449452
//
450453
// WebSocket requests must have the `GET` method and

0 commit comments

Comments
 (0)