nodemailer-fetch
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -175,3 +175,5 @@ 'use strict'; | ||
if (res.statusCode >= 300) { | ||
fetchRes.statusCode = res.statusCode; | ||
if (res.statusCode >= 300 && !options.allowErrorResponse) { | ||
finished = true; | ||
@@ -178,0 +180,0 @@ fetchRes.emit('error', new Error('Invalid status code ' + res.statusCode)); |
{ | ||
"name": "nodemailer-fetch", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "GET HTTP contents", | ||
@@ -5,0 +5,0 @@ "main": "lib/fetch.js", |
@@ -40,2 +40,3 @@ # nodemailer-fetch | ||
* **headers** custom headers as an object where key is the header key and value is either a string or an array of strings for multiple values | ||
* **allowErrorResponse** of true then processes response even if the response code is non 2xx | ||
@@ -42,0 +43,0 @@ ```javascript |
@@ -340,2 +340,20 @@ /* eslint no-unused-expressions:0, prefer-arrow-callback:0 */ | ||
it('should allow invalid status', function (done) { | ||
let req = fetch('http://localhost:' + HTTP_PORT + '/invalid', { | ||
allowErrorResponse: true | ||
}); | ||
let buf = []; | ||
req.on('data', function (chunk) { | ||
buf.push(chunk); | ||
}); | ||
req.on('error', function (err) { | ||
expect(err).to.not.exist; | ||
}); | ||
req.on('end', function () { | ||
expect(req.statusCode).to.equal(500); | ||
expect(Buffer.concat(buf).toString()).to.equal('Hello World HTTP\n'); | ||
done(); | ||
}); | ||
}); | ||
it('should return error for invalid url', function (done) { | ||
@@ -342,0 +360,0 @@ let req = fetch('http://localhost:99999999/'); |
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
52321
1325
57
26