File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ FormData.prototype.getLengthSync = function() {
325325 }
326326
327327 // https://github.com/form-data/form-data/issues/40
328- if ( this . _valuesToMeasure . length ) {
328+ if ( ! this . hasKnownLength ( ) ) {
329329 // Some async length retrievers are present
330330 // therefore synchronous length calculation is false.
331331 // Please use getLength(callback) to get proper length
@@ -335,6 +335,19 @@ FormData.prototype.getLengthSync = function() {
335335 return knownLength ;
336336} ;
337337
338+ // Public API to check if length of added values is known
339+ // https://github.com/form-data/form-data/issues/196
340+ // https://github.com/form-data/form-data/issues/262
341+ FormData . prototype . hasKnownLength = function ( ) {
342+ var hasKnownLength = true ;
343+
344+ if ( this . _valuesToMeasure . length ) {
345+ hasKnownLength = false ;
346+ }
347+
348+ return hasKnownLength ;
349+ } ;
350+
338351FormData . prototype . getLength = function ( cb ) {
339352 var knownLength = this . _overheadLength + this . _valueLength ;
340353
You can’t perform that action at this time.
0 commit comments