multiparty
Advanced tools
Comparing version 4.1.4 to 4.2.0
@@ -0,1 +1,11 @@ | ||
### 4.2.0 | ||
* Douglas Christopher Wilson: | ||
- Use http-errors for raised errors | ||
- Use random-bytes module for polyfill | ||
- perf: remove parameter reassignment | ||
* Graham Hunter | ||
- examples: update placement of response in azureblobstorage | ||
### 4.1.4 | ||
@@ -2,0 +12,0 @@ |
50
index.js
@@ -11,6 +11,7 @@ /*! | ||
var createError = require('http-errors') | ||
var randomBytes = require('random-bytes') | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
var crypto = require('crypto'); | ||
var path = require('path'); | ||
@@ -55,17 +56,16 @@ var os = require('os'); | ||
function Form(options) { | ||
var opts = options || {} | ||
var self = this; | ||
stream.Writable.call(self); | ||
options = options || {}; | ||
self.error = null; | ||
self.autoFields = !!options.autoFields; | ||
self.autoFiles = !!options.autoFiles; | ||
self.autoFields = !!opts.autoFields | ||
self.autoFiles = !!opts.autoFiles | ||
self.maxFields = options.maxFields || 1000; | ||
self.maxFieldsSize = options.maxFieldsSize || 2 * 1024 * 1024; | ||
self.maxFilesSize = options.maxFilesSize || Infinity; | ||
self.uploadDir = options.uploadDir || os.tmpdir(); | ||
self.encoding = options.encoding || 'utf8'; | ||
self.maxFields = opts.maxFields || 1000 | ||
self.maxFieldsSize = opts.maxFieldsSize || 2 * 1024 * 1024 | ||
self.maxFilesSize = opts.maxFilesSize || Infinity | ||
self.uploadDir = opts.uploadDir || os.tmpdir() | ||
self.encoding = opts.encoding || 'utf8' | ||
@@ -658,7 +658,7 @@ self.bytesReceived = 0; | ||
headers: fileStream.headers, | ||
size: 0, | ||
size: 0 | ||
}; | ||
var internalFile = { | ||
publicFile: publicFile, | ||
ws: null, | ||
ws: null | ||
}; | ||
@@ -685,7 +685,5 @@ beginFlush(self); // flush to write stream | ||
internalFile.ws.on('error', function(err) { | ||
if (err.code === 'ETOOBIG') { | ||
err = createError(413, err.message); | ||
err.code = 'ETOOBIG'; | ||
} | ||
self.handleError(err); | ||
self.handleError(err.code === 'ETOOBIG' | ||
? createError(413, err.message, { code: err.code }) | ||
: err) | ||
}); | ||
@@ -781,3 +779,3 @@ internalFile.ws.on('progress', function() { | ||
function randoString(size) { | ||
return rando(size).toString('base64').replace(/[\/\+]/g, function(x) { | ||
return randomBytes.sync(size).toString('base64').replace(/[\/\+]/g, function(x) { | ||
return b64Safe[x]; | ||
@@ -787,10 +785,2 @@ }); | ||
function rando(size) { | ||
try { | ||
return crypto.randomBytes(size); | ||
} catch (err) { | ||
return crypto.pseudoRandomBytes(size); | ||
} | ||
} | ||
function parseFilename(headerValue) { | ||
@@ -819,9 +809,1 @@ var m = headerValue.match(/\bfilename="(.*?)"($|; )/i); | ||
} | ||
function createError(status, message) { | ||
var error = new Error(message); | ||
Error.captureStackTrace(error, createError); | ||
error.status = status; | ||
error.statusCode = status; | ||
return error; | ||
} |
{ | ||
"name": "multiparty", | ||
"description": "multipart/form-data parser which supports streaming", | ||
"version": "4.1.4", | ||
"version": "4.2.0", | ||
"author": "Andrew Kelley <superjoe30@gmail.com>", | ||
@@ -21,2 +21,4 @@ "contributors": [ | ||
"fd-slicer": "~1.0.1", | ||
"http-errors": "~1.6.3", | ||
"random-bytes": "~1.0.0", | ||
"safe-buffer": "5.1.2" | ||
@@ -23,0 +25,0 @@ }, |
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
Network access
Supply chain riskThis module accesses the network.
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
44025
4
699
1
+ Addedhttp-errors@~1.6.3
+ Addedrandom-bytes@~1.0.0
+ Addeddepd@1.1.2(transitive)
+ Addedhttp-errors@1.6.3(transitive)
+ Addedinherits@2.0.3(transitive)
+ Addedrandom-bytes@1.0.0(transitive)
+ Addedsetprototypeof@1.1.0(transitive)
+ Addedstatuses@1.5.0(transitive)