From a23f50a0a18faa20edbdda95ff0c9670252d851d Mon Sep 17 00:00:00 2001 From: Andrew Naylor Date: Fri, 8 Oct 2010 17:46:52 +0100 Subject: [PATCH] Altered the buffering code within feedback handler so that a partial response when data has already buffered will add to the buffer. --- lib/apn.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/apn.js b/lib/apn.js index e6e13ba..67fae60 100644 --- a/lib/apn.js +++ b/lib/apn.js @@ -272,10 +272,15 @@ var Feedback = function (optionArgs) { } var processData = function(data) { - // Need to parse this data in correct lengths; var pos = 0; + // If there is some buffered data read read the remainder and process this first. if(readLength > 0) { - data.copy(readBuffer, readLength, 0, 38-readLength); + if(data.length < (responsePacketLength - readLength)) { + data.copy(readBuffer, readLength, 0); + readLength += data.length; + return; + } + data.copy(readBuffer, readLength, 0, responsePacketLength-readLength); decodeResponse(readBuffer, 0); pos = responsePacketLength-readLength; readLength = 0;