Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@smithy/node-http-handler
Advanced tools
@smithy/node-http-handler is a package that provides HTTP request handling capabilities for Node.js applications. It is part of the Smithy framework, which is used for building SDKs and clients for AWS services. This package is specifically designed to handle HTTP requests and responses, making it easier to interact with web services.
HTTP Request Handling
This feature allows you to handle HTTP requests using the NodeHttpHandler class. The code sample demonstrates how to create an HTTP request and handle the response.
const { NodeHttpHandler } = require('@smithy/node-http-handler');
const { HttpRequest } = require('@smithy/protocol-http');
const handler = new NodeHttpHandler();
const request = new HttpRequest({
hostname: 'example.com',
path: '/path',
method: 'GET'
});
handler.handle(request).then(response => {
console.log(response.statusCode);
console.log(response.body);
}).catch(error => {
console.error(error);
});
Custom HTTP Options
This feature allows you to customize HTTP options such as connection timeout and socket timeout. The code sample demonstrates how to set these options when creating a NodeHttpHandler instance.
const { NodeHttpHandler } = require('@smithy/node-http-handler');
const { HttpRequest } = require('@smithy/protocol-http');
const handler = new NodeHttpHandler({
connectionTimeout: 3000,
socketTimeout: 3000
});
const request = new HttpRequest({
hostname: 'example.com',
path: '/path',
method: 'GET'
});
handler.handle(request).then(response => {
console.log(response.statusCode);
console.log(response.body);
}).catch(error => {
console.error(error);
});
Axios is a popular HTTP client for Node.js and the browser. It provides a simple and easy-to-use API for making HTTP requests. Compared to @smithy/node-http-handler, Axios offers more features such as request and response interceptors, automatic JSON data transformation, and support for canceling requests.
Node-fetch is a lightweight module that brings the Fetch API to Node.js. It is similar to the Fetch API available in browsers and is used for making HTTP requests. Compared to @smithy/node-http-handler, node-fetch is more minimalistic and focuses on providing a simple API for making HTTP requests without additional features.
Got is a powerful and flexible HTTP request library for Node.js. It supports features such as retries, streams, and advanced request options. Compared to @smithy/node-http-handler, Got offers more advanced features and a more flexible API for handling HTTP requests.
This package implements the default requestHandler
for Node.js using node:http
, node:https
, and node:http2
.
For an example on how requestHandler
s are used by Smithy generated SDK clients, refer to
the AWS SDK for JavaScript (v3) supplemental docs.
FAQs
Provides a way to make requests
The npm package @smithy/node-http-handler receives a total of 18,831,726 weekly downloads. As such, @smithy/node-http-handler popularity was classified as popular.
We found that @smithy/node-http-handler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.