thrownewError"The stream has already been prepared for usage; you either piped it or generated the HTTP headers. No new sources can be appended anymore."
contentLength=(left2=options.knownLength!=null?options.knownLength:options.contentLength)!=null?left2 :source.headers!=null?source.headers["content-length"]:undefined;// FIXME: Is this even used anywhere?
thrownewError("The stream has already been prepared for usage; you either piped it or generated the HTTP headers. No new sources can be appended anymore.");
// This method should be called when the user is finished adding streams. It adds the termination header at the end of the combined stream. When piping, this method is automatically called!
debug("called 'done'");
if(!this._closingHeaderAppended){
this._closingHeaderAppended=true;
returnthis._appendClosingHeader();
}
};
FormData.prototype.getBoundary=function(){
}
},{
key:"getBoundary",
value:functiongetBoundary(){
returnthis._boundary;
};
}
},{
key:"getHeaders",
value:functiongetHeaders(callback){
var_this=this;
FormData.prototype.getHeaders=function(callback){
// Returns the headers needed to correctly transmit the generated multipart/form-data blob. We will first need to call @done() to make sure that the multipart footer is there - from this point on, no new sources can be appended anymore.
this.done();
returnPromise["try"]((function(_this){
returnfunction(){
returnPromise.try(function(){
return_this._stream.getCombinedStreamLength();
};
})(this)).then(function(length){
}).then(function(length){
debug("total combined stream length: %s",length);
returnPromise.resolve({
"content-length":length
});
})["catch"](function(err){
}).catch(function(_error){
// We couldn't get the stream length, most likely there was a stream involved that `stream-length` does not support.
debug("WARN: could not get total combined stream length");
contentLength=(left2=options.knownLength!=null?options.knownLength:options.contentLength)!=null?left2:(source.headers!=null?source.headers["content-length"]:undefined);// FIXME: Is this even used anywhere?
}else{// Probably just a plaintext form value, or an unidentified stream
thrownewError("The stream has already been prepared for usage; you either piped it or generated the HTTP headers. No new sources can be appended anymore.");
// This method should be called when the user is finished adding streams. It adds the termination header at the end of the combined stream. When piping, this method is automatically called!
debug("called 'done'");
if(!this._closingHeaderAppended){
this._closingHeaderAppended=true;
returnthis._appendClosingHeader();
}
}
getBoundary(){
returnthis._boundary;
}
getHeaders(callback){
// Returns the headers needed to correctly transmit the generated multipart/form-data blob. We will first need to call @done() to make sure that the multipart footer is there - from this point on, no new sources can be appended anymore.
this.done();
returnPromise.try(()=>{
returnthis._stream.getCombinedStreamLength();
}).then(function(length){
debug("total combined stream length: %s",length);
returnPromise.resolve({"content-length":length});
}).catch(function(_error){
// We couldn't get the stream length, most likely there was a stream involved that `stream-length` does not support.
debug("WARN: could not get total combined stream length");