Socket
Socket
Sign inDemoInstall

reqlib

Package Overview
Dependencies
3
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.6 to 1.0.7

27

dist/index.js

@@ -246,2 +246,3 @@ "use strict";

var executeRequest,
requestContentType,
self = this,

@@ -273,19 +274,23 @@ state = {};

if (!headerExists(options.headers, HTTP_HEADERS.CONTENT_TYPE)) {
requestContentType = coalesce(options.headers[HTTP_HEADERS.CONTENT_TYPE], options.headers[HTTP_HEADERS.CONTENT_TYPE.toLowerCase()]); // default the content type if not provided...
if (!requestContentType) {
// apply application/json header as default (this is opinionated)
options.headers[HTTP_HEADERS.CONTENT_TYPE] = 'application/json'; // serialize data (if provided) as JSON
options.headers[HTTP_HEADERS.CONTENT_TYPE] = 'application/json';
requestContentType = 'application/json';
} // ensure serialization of data
if (isObject(state.data)) {
state.data = (0, _stringify.default)(state.data);
}
} // ensure state data is
if (isObject(state.data) && state.data.toString) {
state.data = state.data.toString();
if (RE_CONTENT_TYPE_JSON.test(requestContentType)) {
state.data = (0, _stringify.default)(data);
} else if (data && data.toString && typeof data.toString === 'function') {
state.data = data.toString();
} // apply content length header
options.headers[HTTP_HEADERS.CONTENT_LENGTH] = options.headers[HTTP_HEADERS.CONTENT_LENGTH] || Buffer.byteLength(state.data); // setup failover if applicable
if (typeof state.data === 'string') {
options.headers[HTTP_HEADERS.CONTENT_LENGTH] = options.headers[HTTP_HEADERS.CONTENT_LENGTH] || Buffer.byteLength(state.data);
} // setup failover if applicable
['host', 'hostname', 'hostnames', 'hosts'].forEach(function (field) {

@@ -510,3 +515,3 @@ var key = RE_ENDS_WITH_S.test(field) ? field.slice(0, -1) : field; // if the host or hostname field value is an Array

if (state.data) {
if (state.data && (typeof state.data === 'string' || Buffer.isBuffer(state.data))) {
client.write(state.data);

@@ -513,0 +518,0 @@ } // finish up the client stream and end to send

@@ -0,1 +1,5 @@

# v1.0.7 - 03/12/2019
* Adjusted how content-length header is calculated and applied for JSON data
# v1.0.6 - 03/05/2019

@@ -2,0 +6,0 @@

{
"name": "reqlib",
"version": "1.0.6",
"version": "1.0.7",
"description": "A library to simplify REST API requests and to provide utilities for handling common REST API consumer scenarios ",

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

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