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

http-call

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-call - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

35

lib/http.js

@@ -43,3 +43,2 @@ 'use strict';

*/
// eslint-disable-line

@@ -71,2 +70,33 @@

/**
* make an http POST request
* @param {string} url - url or path to call
* @param {RequestOptions} options
* @returns {Promise}
* @example
* ```js
* const http = require('http-call')
* await http.post('https://google.com')
* ```
*/
static async post(url, options = {}) {
options.method = 'POST';
let http = new this(url, options);
await http.request();
return http.body;
}
parseBody(body) {
if (!this.headers['Content-Type']) {
this.headers['Content-Type'] = 'application/json';
}
if (this.headers['Content-Type'] === 'application/json') {
this.requestBody = JSON.stringify(body);
} else {
this.requestBody = body;
}
this.headers['Content-Length'] = Buffer.byteLength(this.requestBody).toString();
}
/**
* make a streaming request

@@ -119,2 +149,4 @@ * @param {string} url - url or path to call

this.path = u.path || this.path;
if (options.body) this.parseBody(options.body);
this.body = undefined;
}

@@ -141,2 +173,3 @@

request.on('error', reject);
if (this.requestBody) request.write(this.requestBody);
request.end();

@@ -143,0 +176,0 @@ });

2

package.json
{
"name": "http-call",
"description": "make http requests",
"version": "1.0.15",
"version": "1.0.16",
"author": "Jeff Dickey @dickeyxxx",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/dickeyxxx/http-call/issues",

Sorry, the diff of this file is not supported yet

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