fast-azure-storage
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -30,3 +30,6 @@ 'use strict'; | ||
'ESOCKETTIMEDOUT', | ||
'ECONNREFUSED' | ||
'ECONNREFUSED', | ||
'RequestTimeoutError', | ||
'RequestAbortedError', | ||
'RequestContentLengthError' | ||
]; | ||
@@ -128,2 +131,16 @@ | ||
// Reject on abort which happens if there is a timeout | ||
req.once('abort', function() { | ||
var err = new Error('Requested aborted by client due to timeout'); | ||
err.code = 'RequestTimeoutError'; | ||
reject(err); | ||
}); | ||
// Reject on aborted which happens if the server aborts the request | ||
req.once('aborted', function() { | ||
var err = new Error('Request aborted by server'); | ||
err.code = 'RequestAbortedError'; | ||
reject(err); | ||
}); | ||
// On response, we buffer up the incoming stream and resolve with that | ||
@@ -143,2 +160,9 @@ req.once('response', function(res) { | ||
// Reject on aborted, if server aborts the request | ||
res.once('aborted', function() { | ||
var err = new Error('Request aborted by server'); | ||
err.code = 'RequestAbortedError'; | ||
reject(err); | ||
}); | ||
// Resolve on request end | ||
@@ -148,2 +172,14 @@ res.once('end', function() { | ||
res.payload = chunks.join(''); | ||
// Validate content-length if one was provided | ||
var contentLength = res.headers['content-length']; | ||
if (contentLength) { | ||
var length = Buffer.byteLength(res.payload, 'utf8'); | ||
if (length !== parseInt(contentLength)) { | ||
var err = new Error('Content-Length mismatch'); | ||
err.code = 'RequestContentLengthError'; | ||
return reject(err); | ||
} | ||
} | ||
resolve(res); | ||
@@ -150,0 +186,0 @@ }); |
{ | ||
"name": "fast-azure-storage", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"author": "Jonas Finnemann Jensen <jopsen@gmail.com>", | ||
@@ -20,3 +20,3 @@ "description": "Fast client library for azure storage services", | ||
"promise": "^7.0.4", | ||
"pixl-xml": "^1.0.4" | ||
"pixl-xml": "^1.0.10" | ||
}, | ||
@@ -23,0 +23,0 @@ "optionalDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107446
2306
Updatedpixl-xml@^1.0.10