summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-14 19:42:28 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-14 19:42:28 +0200
commita49a44fc4b06f2675de3a4f7cbc9ac4e477f1c28 (patch)
tree1ed8ca02885d9a3ec77f902821299beb643f5102 /web
parentf7bec31d3ffaf28f34bef0962be74d8de77cbd8f (diff)
Fix two bugs in chunk-parsing code in main.js
Invert a comparison and initialize receivedLength to 0 after emptying receiveBuffer.
Diffstat (limited to 'web')
-rw-r--r--web/main.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/web/main.js b/web/main.js
index 1a299db..d2b84af 100644
--- a/web/main.js
+++ b/web/main.js
@@ -492,12 +492,13 @@ var connectPython = function connectPythonFunc() {
receiveBuffer.push(chunk.substring(offset, i));
bodyLength = +receiveBuffer.join('');
receiveBuffer.length = 0;
+ receivedLength = 0;
}
offset = i + 1;
receivingHeader = false;
continue; // process the packet body in the next iteration
}
- else if ((receivedLength + N - offset) <= bodyLength) {
+ else if ((receivedLength + N - offset) >= bodyLength) {
if (receivedLength == 0) {
// an optimization in case the buffer is empty
s = chunk.substr(offset, bodyLength);