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

bhttp

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bhttp - npm Package Compare versions

Comparing version 1.2.5 to 1.2.6

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 1.2.6 (February 18, 2020)
Oops, accidentally released 1.2.5 a bit too soon!
* __Patch:__ Fixed some Lodash conversion mistakes
## 1.2.5 (February 18, 2020)

@@ -2,0 +8,0 @@

44

lib/bhttp.js

@@ -7,2 +7,10 @@ "use strict"; // FIXME: Force-lowercase user-supplied headers before merging them into the request?

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var urlUtil = require("url");

@@ -95,2 +103,28 @@

function iterateValues(object) {
if (object == null) {
return [];
} else {
return Object.values(object);
}
}
function assign() {
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
objects[_key] = arguments[_key];
}
var validObjects = objects.filter(function (object) {
return object != null;
});
if (validObjects.length === 0) {
return {};
} else if (validObjects.length === 1) {
return validObjects[0];
} else {
return Object.assign.apply(Object, _toConsumableArray(validObjects));
}
}
var ofTypes = function ofTypes(obj, types) {

@@ -215,3 +249,3 @@ var match = false;

var urlOptions = urlUtil.parse(request.url, true);
Object.assign(request.options, {
assign(request.options, {
hostname: urlOptions.hostname,

@@ -297,9 +331,9 @@ port: urlOptions.port

multipart = multipart || Object.values(request.options.formFields).some(function (item) {
multipart = multipart || iterateValues(request.options.formFields).some(function (item) {
return item instanceof Buffer || isStream(item);
}); // Really, 'files' and 'formFields' are the same thing - they mostly have different names for 1) clarity and 2) multipart detection. We combine them here.
Object.assign(request.options.formFields, request.options.files); // For a last sanity check, we want to know whether there are any Stream objects in our form data *at all* - these can't be used when encodeJSON is enabled.
assign(request.options.formFields, request.options.files); // For a last sanity check, we want to know whether there are any Stream objects in our form data *at all* - these can't be used when encodeJSON is enabled.
var containsStreams = Object.values(request.options.formFields).some(function (item) {
var containsStreams = iterateValues(request.options.formFields).some(function (item) {
return isStream(item);

@@ -386,3 +420,3 @@ });

} else {
Object.assign(request.options.headers, headers);
assign(request.options.headers, headers);
return Promise.resolve();

@@ -389,0 +423,0 @@ }

2

package.json
{
"name": "bhttp",
"version": "1.2.5",
"version": "1.2.6",
"description": "A sane HTTP client library for Node.js with Streams2 support.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -89,2 +89,22 @@ "use strict";

function iterateValues(object) {
if (object == null) {
return [];
} else {
return Object.values(object);
}
}
function assign(...objects) {
let validObjects = objects.filter((object) => object != null);
if (validObjects.length === 0) {
return {};
} else if (validObjects.length === 1) {
return validObjects[0];
} else {
return Object.assign(...validObjects);
}
}
const ofTypes = function(obj, types) {

@@ -180,3 +200,3 @@ let match = false;

Object.assign(request.options, {hostname: urlOptions.hostname, port: urlOptions.port});
assign(request.options, {hostname: urlOptions.hostname, port: urlOptions.port});
request.options.path = urlUtil.format({pathname: urlOptions.pathname, query: request.options.query != null ? request.options.query : urlOptions.query});

@@ -239,9 +259,9 @@ request.protocol = urlOptions.protocol.replace(/:$/, "");

// Similarly, if any of the formFields values are either a Stream or a Buffer, we will assume that the form should be sent as multipart.
multipart = multipart || Object.values(request.options.formFields).some((item) => item instanceof Buffer || isStream(item));
multipart = multipart || iterateValues(request.options.formFields).some((item) => item instanceof Buffer || isStream(item));
// Really, 'files' and 'formFields' are the same thing - they mostly have different names for 1) clarity and 2) multipart detection. We combine them here.
Object.assign(request.options.formFields, request.options.files);
assign(request.options.formFields, request.options.files);
// For a last sanity check, we want to know whether there are any Stream objects in our form data *at all* - these can't be used when encodeJSON is enabled.
const containsStreams = Object.values(request.options.formFields).some((item) => isStream(item));
const containsStreams = iterateValues(request.options.formFields).some((item) => isStream(item));

@@ -304,3 +324,3 @@ if (request.options.encodeJSON && containsStreams) {

} else {
Object.assign(request.options.headers, headers);
assign(request.options.headers, headers);
return Promise.resolve();

@@ -307,0 +327,0 @@ }

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