@@ -57,7 +57,7 @@ FormData.prototype.append = function (field, value, options) {
5757var append = CombinedStream . prototype . append . bind ( this ) ;
5858
5959// all that streamy business can't handle numbers
60- if ( typeof value === 'number' ) {
60+ if ( typeof value === 'number' || value == null ) {
6161value = String ( value ) ;
6262}
6363
@@ -231,14 +231,14 @@ FormData.prototype._getContentDisposition = function (value, options) {
231231if ( typeof options . filepath === 'string' ) {
232232// custom filepath for relative paths
233233filename = path . normalize ( options . filepath ) . replace ( / \\ / g, '/' ) ;
234- } else if ( options . filename || value . name || value . path ) {
234+ } else if ( options . filename || ( value && ( value . name || value . path ) ) ) {
235235/*
236236 * custom filename take precedence
237237 * formidable and the browser add a name property
238238 * fs- and request- streams have path property
239239 */
240- filename = path . basename ( options . filename || value . name || value . path ) ;
241- } else if ( value . readable && hasOwn ( value , 'httpVersion' ) ) {
240+ filename = path . basename ( options . filename || ( value && ( value . name || value . path ) ) ) ;
241+ } else if ( value && value . readable && hasOwn ( value , 'httpVersion' ) ) {
242242// or try http response
243243filename = path . basename ( value . client . _httpMessage . path || '' ) ;
244244}
@@ -256,17 +256,17 @@ FormData.prototype._getContentType = function (value, options) {
256256var contentType = options . contentType ;
257257
258258// or try `name` from formidable, browser
259- if ( ! contentType && value . name ) {
259+ if ( ! contentType && value && value . name ) {
260260contentType = mime . lookup ( value . name ) ;
261261}
262262
263263// or try `path` from fs-, request- streams
264- if ( ! contentType && value . path ) {
264+ if ( ! contentType && value && value . path ) {
265265contentType = mime . lookup ( value . path ) ;
266266}
267267
268268// or if it's http-reponse
269- if ( ! contentType && value . readable && hasOwn ( value , 'httpVersion' ) ) {
269+ if ( ! contentType && value && value . readable && hasOwn ( value , 'httpVersion' ) ) {
270270contentType = value . headers [ 'content-type' ] ;
271271}
272272
@@ -276,7 +276,7 @@ FormData.prototype._getContentType = function (value, options) {
276276}
277277
278278// fallback to the default content type if `value` is not simple value
279- if ( ! contentType && typeof value === 'object' ) {
279+ if ( ! contentType && value && typeof value === 'object' ) {
280280contentType = FormData . DEFAULT_CONTENT_TYPE ;
281281}
282282