Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const settings = Hoek.applyToDefaults(internals.defaults, options);
this._boundary = settings.boundary;
this._state = internals.state.preamble;
this._held = '';
this._stream = null;
this._headers = {};
this._name = '';
this._pendingHeader = '';
this._error = null;
this._bytes = 0;
this._maxBytes = settings.maxBytes;
this._parts = new Nigel.Stream(Buffer.from('--' + settings.boundary));
this._lines = new Nigel.Stream(Buffer.from('\r\n'));
this._parts.on('needle', () => this._onPartEnd());
this._parts.on('haystack', (chunk) => this._onPart(chunk));
this._lines.on('needle', () => this._onLineEnd());
this._lines.on('haystack', (chunk) => this._onLine(chunk));
this.once('finish', () => this._parts.end());
this._parts.once('close', () => this._lines.end());
let piper = null;
let finish = (err) => {
if (piper) {
piper.removeListener('data', onReqData);
piper.removeListener('error', finish);
piper.removeListener('aborted', onReqAborted);
}
Hoek.assert(options !== null && typeof options === 'object', 'options must be an object');
const settings = Hoek.applyToDefaults(internals.defaults, options);
this._boundary = settings.boundary;
this._state = internals.state.preamble;
this._held = '';
this._stream = null;
this._headers = {};
this._name = '';
this._pendingHeader = '';
this._error = null;
this._bytes = 0;
this._maxBytes = settings.maxBytes;
this._parts = new Nigel.Stream(Buffer.from('--' + settings.boundary));
this._lines = new Nigel.Stream(Buffer.from('\r\n'));
this._parts.on('needle', () => this._onPartEnd());
this._parts.on('haystack', (chunk) => this._onPart(chunk));
this._lines.on('needle', () => this._onLineEnd());
this._lines.on('haystack', (chunk) => this._onLine(chunk));
this.once('finish', () => this._parts.end());
this._parts.once('close', () => this._lines.end());
let piper = null;
let finish = (err) => {
if (piper) {
piper.removeListener('data', onReqData);
piper.removeListener('error', finish);
piper.removeListener('aborted', onReqAborted);