Comparing version 3.0.0 to 3.0.1
@@ -291,2 +291,7 @@ 'use strict'; | ||
// Set stream timeout | ||
const clientTimeout = this.settings.timeout; | ||
let clientTimeoutId = null; | ||
const dispenser = new Pez.Dispenser(contentType); | ||
@@ -305,2 +310,3 @@ | ||
clearTimeout(clientTimeoutId); | ||
dispenser.removeListener('error', onError); | ||
@@ -319,2 +325,11 @@ dispenser.removeListener('part', onPart); | ||
if (clientTimeout && | ||
clientTimeout > 0) { | ||
clientTimeoutId = setTimeout(() => { | ||
return next(Boom.clientTimeout()); | ||
}, clientTimeout); | ||
} | ||
const set = (name, value) => { | ||
@@ -321,0 +336,0 @@ |
{ | ||
"name": "subtext", | ||
"description": "HTTP payload parsing", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"repository": "git://github.com/hapijs/subtext", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -1470,2 +1470,38 @@ 'use strict'; | ||
}); | ||
it('will timeout correctly for a multipart payload with output as stream', (done) => { | ||
const path = Path.join(__dirname, './file/image.jpg'); | ||
const fileStream = Fs.createReadStream(path); | ||
const form = new FormData(); | ||
form.append('my_file', fileStream); | ||
form.headers = form.getHeaders(); | ||
Subtext.parse(form, null, { parse: true, output: 'stream', timeout: 1 }, (err, parsed) => { | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Request Timeout'); | ||
expect(err.output.statusCode).to.equal(408); | ||
done(); | ||
}); | ||
}); | ||
it('will timeout correctly for a multipart payload with output file', (done) => { | ||
const path = Path.join(__dirname, './file/image.jpg'); | ||
const fileStream = Fs.createReadStream(path); | ||
const form = new FormData(); | ||
form.append('my_file', fileStream); | ||
form.headers = form.getHeaders(); | ||
Subtext.parse(form, null, { parse: true, output: 'file', timeout: 1 }, (err, parsed) => { | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Request Timeout'); | ||
expect(err.output.statusCode).to.equal(408); | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
250321
1497