Merge 8c2add94a2847730bffbbc3ac1e41e8044985ccd into 71c791c11392aaff48d101a7e09b78a3f4d41baa
This commit is contained in:
commit
41250ad806
@ -49,20 +49,21 @@ DocumentHandler.prototype.handleRawGet = function(key, response, skipExpire) {
|
|||||||
DocumentHandler.prototype.handlePost = function(request, response) {
|
DocumentHandler.prototype.handlePost = function(request, response) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var buffer = '';
|
var buffer = '';
|
||||||
|
var cancelled = false;
|
||||||
request.on('data', function(data) {
|
request.on('data', function(data) {
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
response.writeHead(200, { 'content-type': 'application/json' });
|
response.writeHead(200, { 'content-type': 'application/json' });
|
||||||
}
|
}
|
||||||
buffer += data.toString();
|
buffer += data.toString();
|
||||||
if (_this.maxLength && buffer.length > _this.maxLength) {
|
if (_this.maxLength && buffer.length > _this.maxLength) {
|
||||||
_this.cancelled = true;
|
cancelled = true;
|
||||||
winston.warn('document >maxLength', { maxLength: _this.maxLength });
|
winston.warn('document >maxLength', { maxLength: _this.maxLength });
|
||||||
response.writeHead(400, { 'content-type': 'application/json' });
|
response.writeHead(400, { 'content-type': 'application/json' });
|
||||||
response.end(JSON.stringify({ message: 'Document exceeds maximum length.' }));
|
response.end(JSON.stringify({ message: 'Document exceeds maximum length.' }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
request.on('end', function(end) {
|
request.on('end', function(end) {
|
||||||
if (_this.cancelled) return;
|
if (cancelled) return;
|
||||||
_this.chooseKey(function(key) {
|
_this.chooseKey(function(key) {
|
||||||
_this.store.set(key, buffer, function(res) {
|
_this.store.set(key, buffer, function(res) {
|
||||||
if (res) {
|
if (res) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user