From 8c2add94a2847730bffbbc3ac1e41e8044985ccd Mon Sep 17 00:00:00 2001 From: Joe Friedl Date: Mon, 19 Dec 2011 14:20:22 -0600 Subject: [PATCH] Cancellation should only last as long as the handler --- lib/document_handler.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/document_handler.js b/lib/document_handler.js index ba6ec68..8d15a6c 100644 --- a/lib/document_handler.js +++ b/lib/document_handler.js @@ -49,20 +49,21 @@ DocumentHandler.prototype.handleRawGet = function(key, response, skipExpire) { DocumentHandler.prototype.handlePost = function(request, response) { var _this = this; var buffer = ''; + var cancelled = false; request.on('data', function(data) { if (!buffer) { response.writeHead(200, { 'content-type': 'application/json' }); } buffer += data.toString(); if (_this.maxLength && buffer.length > _this.maxLength) { - _this.cancelled = true; + cancelled = true; winston.warn('document >maxLength', { maxLength: _this.maxLength }); response.writeHead(400, { 'content-type': 'application/json' }); response.end(JSON.stringify({ message: 'Document exceeds maximum length.' })); } }); request.on('end', function(end) { - if (_this.cancelled) return; + if (cancelled) return; _this.chooseKey(function(key) { _this.store.set(key, buffer, function(res) { if (res) {