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

supra-http

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supra-http - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

3

dist/enums.d.ts
declare enum CONTENT_TYPE {
TextEventStream = "text/event-stream",
ApplicationJson = "application/json"
ApplicationJson = "application/json",
FormUrlEncoded = "application/x-www-form-urlencoded"
}

@@ -5,0 +6,0 @@ declare enum CACHE_CONTROL {

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

CONTENT_TYPE["ApplicationJson"] = "application/json";
CONTENT_TYPE["FormUrlEncoded"] = "application/x-www-form-urlencoded";
})(CONTENT_TYPE || (CONTENT_TYPE = {}));

@@ -9,0 +10,0 @@ exports.CONTENT_TYPE = CONTENT_TYPE;

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

const fast_url_parser_1 = __importDefault(require("fast-url-parser"));
const querystring_1 = require("querystring");
class Http {

@@ -33,3 +34,8 @@ constructor() {

requestOptions.body : undefined;
const options = this.createRequestOptions(url, requestOptions, requestProvider.agent, requestBody);
const requestFormContent = !requestBody ?
typeof requestOptions.form === "object" ?
querystring_1.stringify(requestOptions.form) :
typeof requestOptions.form === "string" ?
requestOptions.form : undefined : undefined;
const options = this.createRequestOptions(url, requestOptions, requestProvider.agent, requestBody, requestFormContent);
const request = requestProvider.client.request(options, response => {

@@ -49,8 +55,9 @@ compression_1.Compression

.on('timeout', request.abort);
if (requestBody) {
request.write(requestBody);
const writableContent = requestBody || requestFormContent;
if (writableContent) {
request.write(writableContent);
}
request.end();
}
createRequestOptions(targetUrl, options, agent, bodyContent) {
createRequestOptions(targetUrl, options, agent, bodyContent, formContent) {
const url = fast_url_parser_1.default.parse(targetUrl);

@@ -76,2 +83,6 @@ const mergedOptions = {

}
else if (formContent) {
mergedOptions.headers['content-length'] = formContent.length;
mergedOptions.headers['content-type'] = enums_1.CONTENT_TYPE.FormUrlEncoded;
}
return mergedOptions;

@@ -78,0 +89,0 @@ }

@@ -7,2 +7,3 @@ /// <reference types="node" />

body?: string | object;
form?: string | object;
json?: boolean;

@@ -9,0 +10,0 @@ headers?: Record<string, string>;

{
"name": "supra-http",
"version": "1.1.0",
"version": "1.2.0",
"description": "Circuit breaking http client for NodeJs. And it is fast...",

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

Sorry, the diff of this file is not supported yet

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