@altangent/http-client
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "@altangent/http-client", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Simple promise based http/https client for Node", | ||
"main": "src", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha --recursive \"src/**/*.spec.js\"" | ||
}, | ||
@@ -14,4 +14,6 @@ "author": "Brian Mancini <bmancini@gmail.com>", | ||
"mocha": "^4.0.1", | ||
"nock": "^9.4.1", | ||
"sinon": "^4.1.2" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -16,3 +16,3 @@ const https = require('https'); | ||
let msg = Buffer.concat(buffers).toString(); | ||
let error = new Error('HTTPS failed with error code ' + res.statusCode); | ||
let error = new Error('HTTPS failed with status code ' + res.statusCode); | ||
error.statusCode = res.statusCode; | ||
@@ -41,8 +41,14 @@ error.request = opts; | ||
// connect timeout | ||
// set the idle timeout | ||
// from docs: | ||
// Once a socket is assigned to this request and is connected socket.setTimeout() will be called. | ||
// Sets the socket to timeout after timeout milliseconds of inactivity on the socket. | ||
req.setTimeout(idleTimeoutMs, () => req.abort()); | ||
// set a connect timeout | ||
// this is usually handled by the OS, we want to be more aggressive... | ||
// Connect event does not fire on the HTTP request instance | ||
// Instead use the socket event and listen for the connect event on the socket | ||
const connectTimeout = setTimeout(() => req.abort(), connectionTimeoutMs); | ||
// idle timeout | ||
req.setTimeout(idleTimeoutMs, () => req.abort()); | ||
req.on('connect', () => clearTimeout(connectTimeout)); | ||
req.on('socket', socket => socket.on('connect', () => clearTimeout(connectTimeout))); | ||
req.on('error', reject); | ||
@@ -49,0 +55,0 @@ req.end(); |
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
5128
4
148
4