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.
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
bhttp is a CommonJS module and is imported using require().
const bhttp = require('bhttp');
The `get` method is a common way to make HTTP GET requests with bhttp.
const bhttp = require('bhttp');
bhttp.get('http://example.com');
The `post` method is used for making HTTP POST requests, handling various payload types automatically.
const bhttp = require('bhttp');
bhttp.post('http://example.com/api', { data: 'payload' });
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`.
const Promise = require("bluebird");
const bhttp = require("bhttp");
const https = require('https');
// Workaround for bhttp's lack of default HTTPS agent
const httpsAgent = new https.Agent({ rejectUnauthorized: false }); // WARNING: Do not use rejectUnauthorized: false in production
Promise.try(function() {
// Using the custom HTTPS agent for a secure request (example with a test endpoint)
return bhttp.get("https://icanhazip.com/", { agent: httpsAgent });
}).then(function(response) {
console.log("Your IP is:", response.body.toString());
}).catch(function(err) {
console.error("Error fetching IP:", err.message);
});
// Example using nodebacks for a simple HTTP request (no HTTPS agent needed here)
bhttp.get("http://example.com/data", {}, function(err, response) {
if (err) {
console.error("Error with nodeback request:", err.message);
return;
}
console.log("Nodeback response status:", response.statusCode);
});
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.