nodemailer-fetch
Advanced tools
Comparing version 1.2.0 to 1.2.1
# Changelog | ||
## v1.2.1 2016-01-18 | ||
* Enclose http.request into try..catch to get url parse errors | ||
## v1.2.0 2016-01-18 | ||
@@ -4,0 +8,0 @@ |
@@ -56,9 +56,27 @@ 'use strict'; | ||
var req = handler.get({ | ||
host: parsed.hostname, | ||
path: parsed.path, | ||
port: parsed.port ? parsed.port : (parsed.protocol === 'https:' ? 443 : 80), | ||
headers: headers, | ||
rejectUnauthorized: false, | ||
agent: false | ||
var req; | ||
try { | ||
req = handler.get({ | ||
host: parsed.hostname, | ||
path: parsed.path, | ||
port: parsed.port ? parsed.port : (parsed.protocol === 'https:' ? 443 : 80), | ||
headers: headers, | ||
rejectUnauthorized: false, | ||
agent: false | ||
}); | ||
} catch (E) { | ||
finished = true; | ||
setImmediate(function () { | ||
fetchRes.emit('error', E); | ||
}); | ||
return fetchRes; | ||
} | ||
req.on('error', function (err) { | ||
if (finished) { | ||
return; | ||
} | ||
finished = true; | ||
fetchRes.emit('error', err); | ||
}); | ||
@@ -129,11 +147,3 @@ | ||
req.on('error', function (err) { | ||
if (finished) { | ||
return; | ||
} | ||
finished = true; | ||
fetchRes.emit('error', err); | ||
}); | ||
return fetchRes; | ||
} |
{ | ||
"name": "nodemailer-fetch", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "GET HTTP contents", | ||
@@ -5,0 +5,0 @@ "main": "lib/fetch.js", |
@@ -312,2 +312,15 @@ /* eslint no-unused-expressions:0 */ | ||
it('should return error for invalid url', function (done) { | ||
var req = fetch('http://localhost:99999999/'); | ||
var buf = []; | ||
req.on('data', function (chunk) { | ||
buf.push(chunk); | ||
}); | ||
req.on('error', function (err) { | ||
expect(err).to.exist; | ||
done(); | ||
}); | ||
req.on('end', function () {}); | ||
}); | ||
it('should handle basic HTTP auth', function (done) { | ||
@@ -314,0 +327,0 @@ var req = fetch('http://user:pass@localhost:' + HTTP_PORT + '/auth'); |
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
43780
1122
21