Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@altangent/http-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@altangent/http-client - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

src/https.spec.js

8

package.json
{
"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();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc