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

cuddle

Package Overview
Dependencies
Maintainers
2
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cuddle - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

72

index.js

@@ -133,19 +133,20 @@ 'use strict';

this._max_retry = Request.MAX_RETRY;
this._retryables = Request.RETRYABLES;
this._max_retry = Request.MAX_RETRY;
this._retryables = Request.RETRYABLES;
this._formatted_payload = null;
this.method = method;
this.data = '';
this.headers = {};
this.callbacks = {};
this.request_opts = {};
this.retries = 0;
this.auto_format = true;
this.secure = false;
this.follow = false;
this.started = false;
this.encoding = 'utf8';
this.logger = console;
this.errors = [];
this.last_error = null;
this.method = method;
this.data = '';
this.headers = {};
this.callbacks = {};
this.request_opts = {};
this.retries = 0;
this.auto_format = true;
this.secure = false;
this.follow = false;
this.started = false;
this.encoding = 'utf8';
this.logger = console;
this.errors = [];
this.last_error = null;

@@ -321,2 +322,3 @@ this.end = this.then;

send (data) {
this._formatted_payload = null;
this.data = data || '';

@@ -331,3 +333,2 @@ return this;

let new_path = this.path;
let payload = '';

@@ -350,10 +351,25 @@ this.started = true;

}
else if (this.auto_format) {
payload = (!this.headers['Content-Type'] && this.data)
? Request.stringify(this.data)
: JSON.stringify(this.data);
else if (!this._formatted_payload) {
if (this.auto_format) {
/*
Formatting cases:
+------------------------------------------------+
| content-type | data | | format |
|----------------+----------------+----+---------|
| urlencoded | exists | -> | Request |
| urlencoded | null/undefined | -> | JSON |
| json | exists | -> | JSON |
| json | null/undefined | -> | JSON |
| null/undefined | exists | -> | Request |
| null/undefined | null/undefined | -> | JSON |
+------------------------------------------------+
*/
this._formatted_payload = (this.headers['Content-Type'] !== 'application/json' && this.data)
? Request.stringify(this.data)
: JSON.stringify(this.data);
}
else {
this._formatted_payload = this.data;
}
}
else {
payload = this.data;
}

@@ -370,4 +386,6 @@

if (payload) {
this.headers['Content-Length'] = Buffer.byteLength(payload);
if (this._formatted_payload) {
this.headers['Content-Length'] = Buffer.byteLength(
this._formatted_payload
);
}

@@ -394,3 +412,3 @@

if (this.method !== 'GET') {
req.write(payload);
req.write(this._formatted_payload);
}

@@ -397,0 +415,0 @@

{
"name": "cuddle",
"version": "1.3.2",
"version": "1.3.3",
"description": "Cuddle is a minimal, chainable and readability first http client",

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

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