Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

busboy

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

busboy - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

12

lib/main.js
var fs = require('fs'),
EventEmitter = require('events').EventEmitter,
WritableStream = require('stream').Writable

@@ -17,2 +18,3 @@ || require('readable-stream').Writable,

var self = this;
this._done = false;
this._parser = undefined;

@@ -23,8 +25,12 @@

this.parseHeaders(opts.headers);
this.once('finish', function() {
self._parser && self._parser.end();
});
}
inherits(Busboy, WritableStream);
Busboy.prototype.emit = function(ev) {
if (ev === 'finish' && !this._done)
this._parser && this._parser.end();
else
EventEmitter.prototype.emit.apply(this, arguments);
};
Busboy.prototype.parseHeaders = function(headers) {

@@ -31,0 +37,0 @@ this._parser = undefined;

@@ -40,5 +40,5 @@ // TODO:

function checkFinished() {
if (nends === 0 && finished) {
if (nends === 0 && finished && !boy._done) {
finished = false;
process.nextTick(function() { boy.emit('finish'); });
process.nextTick(function() { boy._done = true; boy.emit('finish'); });
}

@@ -235,4 +235,4 @@ }

var self = this;
if (this._nparts === 0)
process.nextTick(function() { self._boy.emit('finish'); });
if (this._nparts === 0 && !self._boy._done)
process.nextTick(function() { self._boy._done = true; self._boy.emit('finish'); });
};

@@ -239,0 +239,0 @@

@@ -205,2 +205,5 @@ var jsencoding = require('../../deps/encoding/encoding'),

UrlEncoded.prototype.end = function() {
if (this.boy._done)
return;
if (this._state === 'key' && this._key.length > 0) {

@@ -217,2 +220,3 @@ this.boy.emit('field', convertVal(this._key, this.charset),

}
this.boy._done = true;
this.boy.emit('finish');

@@ -219,0 +223,0 @@ };

{ "name": "busboy",
"version": "0.1.0",
"version": "0.1.1",
"author": "Brian White <mscdex@mscdex.net>",

@@ -4,0 +4,0 @@ "description": "A streaming parser for HTML form data for node.js",

@@ -92,3 +92,3 @@ Description

res.writeHead(200, { 'Connection': 'close' });
res.end("That 's all folks!");
res.end("That's all folks!");
});

@@ -95,0 +95,0 @@ return req.pipe(busboy);

@@ -1,6 +0,4 @@

var Multipart = require('../lib/types/multipart'),
parseParams = require('../lib/utils').parseParams;
var Busboy = require('..');
var path = require('path'),
EventEmitter = require('events').EventEmitter,
inspect = require('util').inspect,

@@ -108,8 +106,13 @@ assert = require('assert');

var busboy = new EventEmitter(),
mp,
var busboy = new Busboy({
limits: v.limits,
headers: {
'content-type': 'multipart/form-data; boundary=' + v.boundary
}
}),
finishes = 0,
results = [];
busboy.on('field', function(key, val, valTrunc, keyTrunc) {
results.push(['field', key, val, valTrunc, keyTrunc]);
busboy.on('field', function(key, val, keyTrunc, valTrunc) {
results.push(['field', key, val, keyTrunc, valTrunc]);
});

@@ -125,2 +128,3 @@ busboy.on('file', function(fieldname, stream, filename, encoding, mimeType) {

busboy.on('finish', function() {
assert(finishes++ === 0, makeMsg(v.what, 'finish emitted multiple times'));
assert.deepEqual(results.length,

@@ -143,13 +147,7 @@ v.expected.length,

});
var cfg = {
limits: v.limits,
headers: null,
parsedConType: parseParams('multipart/form-data; boundary=' + v.boundary)
};
mp = new Multipart(busboy, cfg);
v.source.forEach(function(s) {
mp.write(new Buffer(s, 'utf8'), EMPTY_FN);
busboy.write(new Buffer(s, 'utf8'), EMPTY_FN);
});
mp.end();
busboy.end();
}

@@ -156,0 +154,0 @@ next();

@@ -1,6 +0,4 @@

var UrlEncoded = require('../lib/types/urlencoded'),
parseParams = require('../lib/utils').parseParams;
var Busboy = require('..');
var path = require('path'),
EventEmitter = require('events').EventEmitter,
inspect = require('util').inspect,

@@ -14,5 +12,2 @@ assert = require('assert');

var parsedConType;
parsedConType = parseParams('application/x-www-form-urlencoded; charset=utf-8');
var tests = [

@@ -139,7 +134,19 @@ { source: ['foo'],

var busboy = new EventEmitter(), ue, results = [];
var busboy = new Busboy({
limits: v.limits,
headers: {
'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
}
}),
finishes = 0,
results = [];
busboy.on('field', function(key, val, keyTrunc, valTrunc) {
results.push([key, val, keyTrunc, valTrunc]);
});
busboy.on('file', function() {
throw new Error(makeMsg(v.what, 'Unexpected file'));
});
busboy.on('finish', function() {
assert(finishes++ === 0, makeMsg(v.what, 'finish emitted multiple times'));
assert.deepEqual(results.length,

@@ -165,13 +172,6 @@ v.expected.length,

var cfg = {
limits: v.limits,
headers: null,
parsedConType: parsedConType
};
ue = new UrlEncoded(busboy, cfg);
v.source.forEach(function(s) {
ue.write(new Buffer(s, 'utf8'), EMPTY_FN);
busboy.write(new Buffer(s, 'utf8'), EMPTY_FN);
});
ue.end();
busboy.end();
}

@@ -178,0 +178,0 @@ next();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc