bhttp is a Node.js HTTP client library designed to provide a sane and intuitive API, offering Streams2 support, automatic payload detection (URL-encoded, multipart/form-data, stream, Buffer, JSON), and robust session management with automatic cookie handling. It differentiates itself from alternatives like the core `http` module, `request`, `needle`, and `hyperquest` by addressing common issues such as low-level API complexity, agent pool blocking, and poor documentation. Key features include easy-to-use promises or nodebacks, multipart/form-data support with Streams2, and progress events for uploads and downloads. The package is currently at version 1.2.8, but its npm and GitHub activity indicate it has been abandoned for several years, making new releases unlikely.
npm install bhttpVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates making both promise-based and nodeback-style GET requests. It includes a critical workaround for bhttp's default HTTPS limitation, illustrating how to use a custom `https.Agent`.
Always provide a custom `https.Agent` with appropriate SSL/TLS settings when making HTTPS requests. Example: `const https = require('https'); const agent = new https.Agent({ rejectUnauthorized: true }); bhttp.get(url, { agent: agent });`Consider migrating to actively maintained HTTP client libraries such as `axios`, `node-fetch`, or the built-in `fetch` API in Node.js for new projects and existing applications.
Thoroughly test stream-based operations in your target Node.js environment. For new stream-heavy applications, prefer modern alternatives that natively support `async` iterators and Web Streams.
Provide a `https.Agent` to `bhttp`'s options. For example: `const https = require('https'); const agent = new https.Agent({ rejectUnauthorized: true }); bhttp.get('https://example.com', { agent: agent });`Ensure `bhttp` is correctly imported as a CommonJS module: `const bhttp = require('bhttp');`. Verify that `bhttp` is installed (`npm install bhttp`) and the path is correct.