New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bbc/http-transport

Package Overview
Dependencies
Maintainers
20
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bbc/http-transport - npm Package Compare versions

Comparing version 4.3.0 to 4.4.0

28

lib/transport/node-fetch.js

@@ -6,8 +6,6 @@ 'use strict';

const http = require('node:http');
const HttpsProxyAgent = require('https-proxy-agent').HttpsProxyAgent;
const HttpProxyAgent = require('http-proxy-agent').HttpProxyAgent;
const fetch = require('node-fetch');
const REQUIRED_PROPERTIES = [
'body',
'elapsedTime',
'url',

@@ -27,3 +25,3 @@ 'statusCode',

if (options?.defaults?.proxy) {
this._httpsProxyAgent = new HttpsProxyAgent(options.defaults.proxy, options?.agentOpts);
this._httpProxyAgent = new HttpProxyAgent(options.defaults.proxy, options?.agentOpts);
}

@@ -77,8 +75,12 @@

// currently supports json and text formats only
to.body = await from.text();
const contentType = to.headers['content-type'];
if (this.parseAsJson(ctx, contentType)) {
try {
to.body = JSON.parse(to.body);
} catch {} // If body is not parseable, leave as text
const text = await from.text();
if (text) {
to.body = text;
const contentType = to.headers['content-type'];
if (this.parseAsJson(ctx, contentType)) {
try {
to.body = JSON.parse(to.body);
} catch {} // If body is not parseable, leave as text
}
}

@@ -91,6 +93,6 @@

selectAgent(ctx) {
if (this._httpsProxyAgent) return this._httpsProxyAgent;
if (this?.defaults?.proxy) return this._httpProxyAgent;
const protocol = new URL(ctx.req.getUrl()).protocol;
return protocol === 'http:' ? this._httpAgent : this._httpsAgent;
const http = new URL(ctx.req.getUrl()).protocol === 'http:';
return http ? this._httpAgent : this._httpsAgent;
}

@@ -97,0 +99,0 @@

{
"name": "@bbc/http-transport",
"version": "4.3.0",
"version": "4.4.0",
"description": "A flexible, modular REST client built for ease-of-use and resilience.",

@@ -51,3 +51,3 @@ "main": "index.js",

"dependencies": {
"https-proxy-agent": "^7.0.2",
"http-proxy-agent": "^7.0.0",
"koa-compose": "^4.0.0",

@@ -54,0 +54,0 @@ "lodash": "^4.17.4",

@@ -86,3 +86,3 @@ 'use strict';

assert.deepEqual(res.body, '');
assert.deepEqual(res.body, undefined);
});

@@ -558,6 +558,5 @@

nock.cleanAll();
api.get(path).reply(200, responseBody);
api.get(path).reply(200, '1234');
const client = HttpTransport.createBuilder()
.use(toJson())
.createClient();

@@ -567,3 +566,3 @@

.use(setContextProperty({
time: false
json: true
},

@@ -575,3 +574,3 @@ 'opts'

assert.isUndefined(res.elapsedTime);
assert.strictEqual(res.body, 1234);
});

@@ -578,0 +577,0 @@

@@ -372,3 +372,3 @@ 'use strict';

it('selects proxy httpsAgent when protocol proxy has been provided', () => {
it('selects httpProxyAgent when proxy has been provided', () => {
const ctx = createContext(url);

@@ -390,3 +390,4 @@ const options = {

sinon.assert.calledWithMatch(spy, url, { agent: {
proxy: new URL(proxyUrl)
proxy: new URL(proxyUrl),
protocol: 'http:'
} });

@@ -396,3 +397,3 @@ });

it('selects proxy httpsAgent when protocol proxy has been provided and applies agent options', () => {
it('selects httpProxyAgent when proxy has been provided and applies agent options', () => {
const ctx = createContext(url);

@@ -399,0 +400,0 @@ const options = {

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