Socket
Socket
Sign inDemoInstall

http2-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http2-wrapper - npm Package Compare versions

Comparing version 2.1.4 to 2.1.5

2

package.json
{
"name": "http2-wrapper",
"version": "2.1.4",
"version": "2.1.5",
"description": "HTTP2 client, just with the familiar `https` API",

@@ -5,0 +5,0 @@ "main": "source",

@@ -12,2 +12,3 @@ 'use strict';

const calculateServerName = require('./utils/calculate-server-name.js');
const delayAsyncDestroy = require('./utils/delay-async-destroy.js');

@@ -127,3 +128,3 @@ const cache = new QuickLRU({maxSize: 100});

options.session = options.tlsSession;
options.servername = options.servername || calculateServerName(options);
options.servername = options.servername || calculateServerName(options.headers?.host || options.host);
options.port = options.port || (isHttps ? 443 : 80);

@@ -196,3 +197,3 @@ options._defaultAgent = isHttps ? https.globalAgent : http.globalAgent;

if (isHttp2) {
return new Http2ClientRequest(options, callback);
return delayAsyncDestroy(new Http2ClientRequest(options, callback));
}

@@ -203,3 +204,3 @@ } else if (agent) {

return http.request(options, callback);
return delayAsyncDestroy(http.request(options, callback));
};

@@ -206,0 +207,0 @@

'use strict';
/* istanbul ignore file: https://github.com/nodejs/node/blob/v13.0.1/lib/_http_agent.js */
const assert = require('assert');
module.exports = options => {
let servername = options.host;
const hostHeader = options.headers && options.headers.host;
module.exports = host => {
// Note: 1.1.1.1 is a valid servername as well!
if (hostHeader) {
if (hostHeader.startsWith('[')) {
const index = hostHeader.indexOf(']');
servername = index === -1 ? hostHeader : hostHeader.slice(1, -1);
} else {
servername = hostHeader.split(':', 1)[0];
}
if (host[0] === '[') {
const idx = host.indexOf(']');
assert(idx !== -1);
return host.slice(1, idx);
}
// Removed empty string return for IP,
// otherwise https://1.1.1.1/ would fail.
const idx = host.indexOf(':');
if (idx === -1) {
return host;
}
return servername;
return host.slice(0, idx);
};
'use strict';
module.exports = stream => {
if (stream.listenerCount('error') !== 0) {
return;
}
stream.__destroy = stream._destroy;

@@ -13,2 +17,18 @@ stream._destroy = async (...args) => {

};
const onError = error => {
// eslint-disable-next-line promise/prefer-await-to-then
Promise.resolve().then(() => {
stream.emit('error', error);
});
};
stream.once('error', onError);
// eslint-disable-next-line promise/prefer-await-to-then
Promise.resolve().then(() => {
stream.off('error', onError);
});
return stream;
};
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