diff --git a/example/server.js b/example/server.js index 455e259..66d8f89 100644 --- a/example/server.js +++ b/example/server.js @@ -30,6 +30,17 @@ function onRequest(request, response) { fileStream.on('finish',response.end); } + // Example for testing large (boundary-sized) frames. + else if (request.url === "/largeframe") { + response.writeHead(200); + var body = 'a'; + for (var i = 0; i < 14; i++) { + body += body; + } + body = body + 'a'; + response.end(body); + } + // Otherwise responding with 404. else { response.writeHead(404); diff --git a/lib/protocol/flow.js b/lib/protocol/flow.js index 1647807..75562f0 100644 --- a/lib/protocol/flow.js +++ b/lib/protocol/flow.js @@ -249,8 +249,9 @@ Flow.prototype._parentPush = function _parentPush(frame) { // did not push the whole frame to the output queue (but maybe it did push part of the frame). Flow.prototype._push = function _push(frame) { var data = frame && (frame.type === 'DATA') && frame.data; + var maxFrameLength = (this._window < 16384) ? this._window : 16384; - if (!data || (data.length <= this._window)) { + if (!data || (data.length <= maxFrameLength)) { return this._parentPush(frame); } @@ -261,12 +262,12 @@ Flow.prototype._push = function _push(frame) { else { this._log.trace({ frame: frame, size: frame.data.length, forwardable: this._window }, 'Splitting out forwardable part of a DATA frame.'); - frame.data = data.slice(this._window); + frame.data = data.slice(maxFrameLength); this._parentPush({ type: 'DATA', flags: {}, stream: frame.stream, - data: data.slice(0, this._window) + data: data.slice(0, maxFrameLength) }); return null; }