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

@smithy/node-http-handler

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/node-http-handler - npm Package Compare versions

Comparing version 2.4.2 to 2.4.3

17

dist-cjs/index.js

@@ -135,7 +135,18 @@ var __create = Object.create;

body.pipe(httpRequest);
} else if (body) {
return;
}
if (body) {
if (Buffer.isBuffer(body) || typeof body === "string") {
httpRequest.end(body);
return;
}
const uint8 = body;
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
return;
}
httpRequest.end(Buffer.from(body));
} else {
httpRequest.end();
return;
}
httpRequest.end();
}

@@ -142,0 +153,0 @@ __name(writeBody, "writeBody");

@@ -52,1 +52,31 @@ import { readFileSync } from "fs";

};
export const createMirrorResponseFunction = (httpResp) => (request, response) => {
const bufs = [];
request.on("data", (chunk) => {
bufs.push(chunk);
});
request.on("end", () => {
response.statusCode = httpResp.statusCode;
setResponseHeaders(response, httpResp.headers);
setResponseBody(response, Buffer.concat(bufs));
});
request.on("error", (err) => {
response.statusCode = 500;
setResponseHeaders(response, httpResp.headers);
setResponseBody(response, err.message);
});
};
export const getResponseBody = (response) => {
return new Promise((resolve, reject) => {
const bufs = [];
response.body.on("data", function (d) {
bufs.push(d);
});
response.body.on("end", function () {
resolve(Buffer.concat(bufs).toString());
});
response.body.on("error", (err) => {
reject(err);
});
});
};

20

dist-es/write-request-body.js

@@ -33,9 +33,21 @@ import { Readable } from "stream";

body.pipe(httpRequest);
return;
}
else if (body) {
if (body) {
if (Buffer.isBuffer(body) || typeof body === "string") {
httpRequest.end(body);
return;
}
const uint8 = body;
if (typeof uint8 === "object" &&
uint8.buffer &&
typeof uint8.byteOffset === "number" &&
typeof uint8.byteLength === "number") {
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
return;
}
httpRequest.end(Buffer.from(body));
return;
}
else {
httpRequest.end();
}
httpRequest.end();
}

@@ -11,1 +11,3 @@ import { HttpResponse } from "@smithy/types";

export declare const createMockHttp2Server: () => Http2Server;
export declare const createMirrorResponseFunction: (httpResp: HttpResponse) => (request: IncomingMessage, response: ServerResponse) => void;
export declare const getResponseBody: (response: HttpResponse) => Promise<string>;

@@ -11,1 +11,3 @@ import { HttpResponse } from "@smithy/types";

export declare const createMockHttp2Server: () => Http2Server;
export declare const createMirrorResponseFunction: (httpResp: HttpResponse) => (request: IncomingMessage, response: ServerResponse) => void;
export declare const getResponseBody: (response: HttpResponse) => Promise<string>;
{
"name": "@smithy/node-http-handler",
"version": "2.4.2",
"version": "2.4.3",
"description": "Provides a way to make requests",

@@ -5,0 +5,0 @@ "scripts": {

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