Registry / http-networking / hagent

hagent

JSON →
library0.0.1jsnpmunverified

hagent is a foundational Node.js module designed to provide HTTP and HTTPS agent functionality specifically tailored for use with Whistle, a cross-platform network debugging and proxy tool. It enables Whistle to manage and proxy network requests at a lower level, handling connection pooling and socket management. Currently at version `0.9.3`, the package has not seen active development since 2020, with its last commit dating back approximately four years. This indicates an abandoned status, meaning it is no longer maintained and may not be compatible with newer Node.js versions or contain unpatched vulnerabilities. Its core functionality revolves around extending Node.js's native `http.Agent` to integrate with Whistle's proxying mechanisms, offering control over persistent connections.

npm install hagent
INSTALL
IMPORT
SIG · HAGENT
H
hagent
http-networkingjavascriptv0.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpClientAgent
const { HttpClientAgent } = require('hagent');
import { HttpClientAgent } from 'hagent'; // hagent@0.9.3 is CommonJS-only const HttpClientAgent = require('hagent').HttpClientAgent; // Not strictly wrong, but destructuring is cleaner
This package is CommonJS-only. There is no ESM support in v0.9.3.
HttpsClientAgent
const { HttpsClientAgent } = require('hagent');
import { HttpsClientAgent } from 'hagent'; // hagent@0.9.3 is CommonJS-only
Used for HTTPS connections; similar CommonJS-only import as HttpClientAgent.
hagent (default export)
const hagent = require('hagent'); // Then access hagent.HttpClientAgent or hagent.HttpsClientAgent
The package exports an object containing both HttpClientAgent and HttpsClientAgent as named properties, not a default export in the traditional sense. Direct destructuring is often preferred.

This quickstart demonstrates how to instantiate and use `HttpClientAgent` to make an HTTP request. The agent is configured to connect through a hypothetical Whistle proxy, showing how it would be integrated into a Node.js HTTP client call.

const http = require('http'); const { HttpClientAgent } = require('hagent'); // Configure a basic HTTP agent for use with Whistle const agent = new HttpClientAgent({ // These options are standard for Node.js http.Agent keepAlive: true, maxSockets: 10, maxFreeSockets: 5, // The 'whistle' option is specific to how hagent integrates // It typically holds configurations like the Whistle server address // For demonstration, we'll use a placeholder whistle server address whistle: { host: '127.0.0.1', port: 8899, // Default Whistle proxy port }, }); const options = { hostname: 'example.com', port: 80, path: '/', method: 'GET', agent: agent, // Use the hagent instance }; const req = http.request(options, (res) => { console.log(`STATUS: ${res.statusCode}`); console.log(`HEADERS: ${JSON.stringify(res.headers)}`); res.setEncoding('utf8'); let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }); res.on('end', () => { try { console.log('Response Body Snippet:', rawData.substring(0, 200) + '...'); } catch (e) { console.error(e.message); } }); }); req.on('error', (e) => { console.error(`problem with request: ${e.message}`); }); // Write data to request body req.end();
Debug
Known issues
breakingThe `hagent` package has been abandoned since April 2020. It is unlikely to be compatible with modern Node.js versions (e.g., Node.js 16+), potentially leading to runtime errors, unexpected behavior, or security vulnerabilities.
fix
Consider migrating to actively maintained HTTP agent solutions or newer versions of Whistle that might embed similar functionality or provide alternative integration points. If Whistle itself is still in use, check its documentation for recommended agent configurations.
affects: >=0.9.3
gotchaThis package is strictly CommonJS (`require`) and does not provide ES Module (`import`) support. Attempting to use `import { HttpClientAgent } from 'hagent'` will result in a module resolution error.
fix
Always use `const { HttpClientAgent } = require('hagent');` or `const hagent = require('hagent');` for module imports.
affects: >=0.1.0
gotchaDue to its abandoned status, `hagent` likely contains unpatched security vulnerabilities or bugs. Using it in production environments is highly discouraged as it poses a significant security risk.
fix
Perform a thorough security audit before considering use, or ideally, replace with a maintained alternative. Rely on Whistle's own mechanisms if they provide a maintained HTTP agent solution.
affects: >=0.9.3
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported.
Attempting to use `require()` on a package that is ESM-only, or more likely in this context, attempting to use `import` with a CommonJS-only package like `hagent`.
fix
Ensure you are using `require()` for this CommonJS-only package: `const { HttpClientAgent } = require('hagent');`
TypeError: Cannot read property 'request' of undefined (or similar for http/https methods)
This error typically indicates that the `agent` object passed to `http.request` or `https.request` is not a valid agent instance, or that the `http` module itself is not correctly imported.
fix
Verify that `hagent` is correctly installed (`npm install hagent`) and that `HttpClientAgent` or `HttpsClientAgent` are correctly imported and instantiated before being passed to Node.js's native `http.request` or `https.request` methods.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
26
Resources