diff options
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/form-data/lib/form_data.js')
-rw-r--r-- | deps/npm/node_modules/request/node_modules/form-data/lib/form_data.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/deps/npm/node_modules/request/node_modules/form-data/lib/form_data.js b/deps/npm/node_modules/request/node_modules/form-data/lib/form_data.js index 8252e6588d..d2cc924918 100644 --- a/deps/npm/node_modules/request/node_modules/form-data/lib/form_data.js +++ b/deps/npm/node_modules/request/node_modules/form-data/lib/form_data.js @@ -325,7 +325,7 @@ FormData.prototype.getLengthSync = function() { } // https://github.com/form-data/form-data/issues/40 - if (this._valuesToMeasure.length) { + if (!this.hasKnownLength()) { // Some async length retrievers are present // therefore synchronous length calculation is false. // Please use getLength(callback) to get proper length @@ -335,6 +335,19 @@ FormData.prototype.getLengthSync = function() { return knownLength; }; +// Public API to check if length of added values is known +// https://github.com/form-data/form-data/issues/196 +// https://github.com/form-data/form-data/issues/262 +FormData.prototype.hasKnownLength = function() { + var hasKnownLength = true; + + if (this._valuesToMeasure.length) { + hasKnownLength = false; + } + + return hasKnownLength; +}; + FormData.prototype.getLength = function(cb) { var knownLength = this._overheadLength + this._valueLength; |