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

@hqoss/http-client

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hqoss/http-client - npm Package Compare versions

Comparing version 0.1.12-0 to 0.1.13-0

44

dist/lib/httpClient/httpClient.js

@@ -19,7 +19,7 @@ "use strict";

// Error reading response
// response.once("error", error => {
// resolver.emit("reject", error)
// req.removeAllListeners()
// response.removeAllListeners()
// })
response.once("error", (error) => {
resolver.emit("reject", error);
req.removeAllListeners();
response.removeAllListeners();
});
// Premature connection close after response has been received

@@ -31,21 +31,18 @@ response.once("aborted", () => {

});
// const chunks: Array<Buffer> = []
// response.once("data", chunk => {
// chunks.push(chunk)
// })
// response.on("end", () => {
// resolver.emit("resolve", Buffer.concat(chunks))
// req.removeAllListeners()
// response.removeAllListeners()
// })
transform_1.toBuffer(response)
.then((tranformedResponse) => {
resolver.emit("resolve", tranformedResponse);
const chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
response.once("end", () => {
const { headers, statusCode, statusMessage } = response;
const transformedResponse = {
headers,
statusClass: transform_1.getStatusClass(statusCode),
statusCode,
statusMessage,
data: Buffer.concat(chunks),
};
resolver.emit("resolve", transformedResponse);
req.removeAllListeners();
response.removeAllListeners();
})
.catch((error) => {
resolver.emit("reject", error);
req.removeAllListeners();
response.removeAllListeners();
});

@@ -57,2 +54,5 @@ });

});
req.once("end", () => {
req.removeAllListeners();
});
req.end();

@@ -59,0 +59,0 @@ if (this.willSendRequest) {

/// <reference types="node" />
import { IncomingMessage } from "http";
import { TransformedResponse } from "./types";
import { StatusClass, TransformedResponse } from "./types";
export declare const toBuffer: (response: IncomingMessage) => Promise<TransformedResponse<Buffer>>;
export declare const toJSON: <T = any>(response: IncomingMessage) => Promise<TransformedResponse<T>>;
export declare const getStatusClass: (statusCode?: number | undefined) => StatusClass;
//# sourceMappingURL=transform.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toJSON = exports.toBuffer = void 0;
exports.getStatusClass = exports.toJSON = exports.toBuffer = void 0;
const http_1 = require("http");

@@ -14,3 +14,3 @@ const types_1 = require("./types");

headers,
statusClass: getStatusClass(statusCode),
statusClass: exports.getStatusClass(statusCode),
statusCode,

@@ -38,3 +38,3 @@ statusMessage,

};
const getStatusClass = (statusCode) => {
exports.getStatusClass = (statusCode) => {
if (!statusCode)

@@ -41,0 +41,0 @@ return types_1.StatusClass.Unknown;

@@ -11,4 +11,5 @@ import { Agent, IncomingMessage, RequestOptions, request } from "http";

} from "./types";
import { toBuffer } from "./transform";
import { getStatusClass } from "./transform";
export class HttpClient {

@@ -53,8 +54,8 @@ private readonly baseReqOpts: RequestOptions;

// Error reading response
// response.once("error", error => {
// resolver.emit("reject", error)
response.once("error", (error) => {
resolver.emit("reject", error);
// req.removeAllListeners()
// response.removeAllListeners()
// })
req.removeAllListeners();
response.removeAllListeners();
});

@@ -74,28 +75,24 @@ // Premature connection close after response has been received

// const chunks: Array<Buffer> = []
const chunks: Array<Buffer> = [];
// response.once("data", chunk => {
// chunks.push(chunk)
// })
response.on("data", (chunk) => {
chunks.push(chunk);
});
// response.on("end", () => {
// resolver.emit("resolve", Buffer.concat(chunks))
response.once("end", () => {
const { headers, statusCode, statusMessage } = response;
// req.removeAllListeners()
// response.removeAllListeners()
// })
const transformedResponse = {
headers,
statusClass: getStatusClass(statusCode),
statusCode,
statusMessage,
data: Buffer.concat(chunks),
};
toBuffer(response)
.then((tranformedResponse) => {
resolver.emit("resolve", tranformedResponse);
resolver.emit("resolve", transformedResponse);
req.removeAllListeners();
response.removeAllListeners();
})
.catch((error) => {
resolver.emit("reject", error);
req.removeAllListeners();
response.removeAllListeners();
});
req.removeAllListeners();
response.removeAllListeners();
});
});

@@ -108,2 +105,6 @@

req.once("end", () => {
req.removeAllListeners();
});
req.end();

@@ -110,0 +111,0 @@

@@ -48,3 +48,3 @@ import { IncomingMessage } from "http";

const getStatusClass = (statusCode?: number): StatusClass => {
export const getStatusClass = (statusCode?: number): StatusClass => {
if (!statusCode) return StatusClass.Unknown;

@@ -51,0 +51,0 @@ if (statusCode >= 100 && statusCode < 200) return StatusClass.Informational;

{
"name": "@hqoss/http-client",
"version": "0.1.12-0",
"version": "0.1.13-0",
"description": "A light-weight, performant, composable blueprint for writing consistent and re-usable Node.js HTTP clients",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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