Socket
Socket
Sign inDemoInstall

agent-base

Package Overview
Dependencies
1
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.1 to 4.3.0

index.d.ts

4

package.json
{
"name": "agent-base",
"version": "4.2.1",
"version": "4.3.0",
"description": "Turn a function into an `http.Agent` instance",

@@ -26,2 +26,4 @@ "main": "./index.js",

"devDependencies": {
"@types/es6-promisify": "^5.0.0",
"@types/node": "^10.5.3",
"mocha": "^3.4.2",

@@ -28,0 +30,0 @@ "ws": "^3.0.0"

@@ -11,17 +11,21 @@ 'use strict';

*/
https.request = (function(request) {
return function(_options, cb) {
let options;
if (typeof _options === 'string') {
options = url.parse(_options);
} else {
options = Object.assign({}, _options);
}
if (null == options.port) {
options.port = 443;
}
options.secureEndpoint = true;
return request.call(https, options, cb);
};
})(https.request);
const patchMarker = "__agent_base_https_request_patched__";
if (!https.request[patchMarker]) {
https.request = (function(request) {
return function(_options, cb) {
let options;
if (typeof _options === 'string') {
options = url.parse(_options);
} else {
options = Object.assign({}, _options);
}
if (null == options.port) {
options.port = 443;
}
options.secureEndpoint = true;
return request.call(https, options, cb);
};
})(https.request);
https.request[patchMarker] = true;
}

@@ -34,3 +38,13 @@ /**

*/
https.get = function(options, cb) {
https.get = function (_url, _options, cb) {
let options;
if (typeof _url === 'string' && _options && typeof _options !== 'function') {
options = Object.assign({}, url.parse(_url), _options);
} else if (!_options && !cb) {
options = _url;
} else if (!cb) {
options = _url;
cb = _options;
}
const req = https.request(options, cb);

@@ -37,0 +51,0 @@ req.end();

@@ -192,5 +192,6 @@ /**

var req = http.request(opts, function(res) {
assert.equal('0.9', res.httpVersion);
assert.equal(111, res.statusCode);
assert.equal('1.0', res.httpVersion);
assert.equal(200, res.statusCode);
assert.equal('bar', res.headers.foo);
assert.deepEqual(['1', '2'], res.headers['set-cookie']);
done();

@@ -203,4 +204,4 @@ });

req.once('socket', function() {
var buf = new Buffer(
'HTTP/0.9 111\r\n' +
var buf = Buffer.from(
'HTTP/1.0 200\r\n' +
'Foo: bar\r\n' +

@@ -546,2 +547,21 @@ 'Set-Cookie: 1\r\n' +

it('should support the 3-argument `https.get()`', function(done) {
var agent = new Agent(function(req, opts, fn) {
assert.equal('google.com', opts.host);
assert.equal('/q', opts.pathname || opts.path);
assert.equal('881', opts.port);
assert.equal('bar', opts.foo);
done();
});
https.get(
'https://google.com:881/q',
{
host: 'google.com',
foo: 'bar',
agent: agent
}
);
});
it('should default to port 443', function(done) {

@@ -565,2 +585,13 @@ var agent = new Agent(function(req, opts, fn) {

it('should not re-patch https.request', () => {
var patchModulePath = "../patch-core";
var patchedRequest = https.request;
delete require.cache[require.resolve(patchModulePath)];
require(patchModulePath);
assert.equal(patchedRequest, https.request);
assert.equal(true, https.request.__agent_base_https_request_patched__);
});
describe('PassthroughAgent', function() {

@@ -567,0 +598,0 @@ it('should pass through to `https.globalAgent`', function(done) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc