Registry / http-networking / http-https

http-https

JSON →
library1.0.0jsnpmunverified

The `http-https` package, at its sole stable version `1.0.0`, is a minimal wrapper designed to simplify making HTTP or HTTPS requests in Node.js. It automatically selects the appropriate native module (`http` or `https`) based on the protocol found in the target URL, exposing a unified `request` method similar to `http.request`. This package was published over a decade ago (around 2012) by Isaac Schlueter and has seen no updates, new features, or bug fixes since its initial release. Consequently, it is an abandoned project and is not actively maintained. While it streamlined basic outbound web requests in older Node.js environments, modern applications should consider actively maintained alternatives that offer current best practices, better error handling, and broader feature sets.

npm install http-https
INSTALL
IMPORT
SIG · HTTP-HTTPS
H
http-https
http-networkingjavascriptv1.0.0
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.

hh
const hh = require('http-https')
import hh from 'http-https'
This package is CommonJS-only and does not provide an ESM export. Use `require`.
request
const { request } = require('http-https')
import { request } from 'http-https'
The primary API is the `request` method, accessed as a property of the main export.
url.parse
const url = require('url'); url.parse('...')
new URL('...').href
The package's examples use `url.parse`, which is a legacy API in Node.js. The modern `URL` constructor is preferred but is not directly used or abstracted by this package.

Demonstrates making both HTTP and HTTPS requests using the `http-https` wrapper, showing how it automatically handles protocol selection, and illustrating its compatibility with both URL strings and parsed URL objects (using Node's built-in `url` module).

const hh = require('http-https'); const url = require('url'); // Node.js built-in url module // Example 1: Direct URL string const simpleReq = hh.request('http://example.com/bar', (res) => { console.log(`HTTP Status: ${res.statusCode}`); res.setEncoding('utf8'); let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }); res.on('end', () => { console.log('Simple HTTP Response received.'); }); }); simpleReq.on('error', (e) => console.error(`Simple request error: ${e.message}`)); simpleReq.end(); // Example 2: With parsed URL object and custom headers const someUrlMaybeHttpMaybeHttps = 'https://secure.example.com/foo'; const parsedOpt = url.parse(someUrlMaybeHttpMaybeHttps); parsedOpt.headers = { 'User-Agent': 'flergy mc flerg/1.0' }; parsedOpt.method = 'GET'; // Changed to GET for typical fetch const secureReq = hh.request(parsedOpt, (res) => { console.log(`HTTPS Status: ${res.statusCode}, Headers: ${JSON.stringify(res.headers)}`); res.setEncoding('utf8'); let rawData = ''; res.on('data', (chunk) => { rawData += chunk; }); res.on('end', () => { console.log('Secure HTTPS Response received.'); }); }); secureReq.on('error', (e) => console.error(`Secure request error: ${e.message}`)); secureReq.end();
Debug
Known issues
breakingThis package is abandoned and has not been updated in over a decade. It does not receive security patches, bug fixes, or feature updates. Using it in production environments is strongly discouraged due to potential vulnerabilities and compatibility issues with modern Node.js.
fix
Migrate to actively maintained alternatives like `node-fetch`, `axios`, or Node.js's native `undici` module, which offer modern features, better performance, and ongoing security support.
affects: >=1.0.0
gotchaThe package uses Node.js's legacy `url.parse` API in its examples and internal logic, which is deprecated in favor of the global `URL` constructor. While `url.parse` still works, it's considered outdated and has known quirks.
fix
When constructing options objects, use the modern `new URL()` constructor to parse URLs and then extract properties (e.g., `urlObject.hostname`, `urlObject.port`, `urlObject.pathname`) to build the options for `http-https.request`.
affects: >=1.0.0
gotchaThis package is CommonJS-only and does not provide an ECMAScript Module (ESM) export. Attempting to `import` it will result in an error in pure ESM environments or require explicit CJS compatibility wrappers.
fix
Ensure your project is configured for CommonJS or use dynamic `import()` if you must use it in an ESM context (e.g., `const hh = await import('http-https');`). However, migrating to a modern, ESM-compatible library is the recommended approach.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: hh.request is not a function
Attempting to use `hh.request` when `http-https` was imported incorrectly or when `require` returns `undefined`.
fix
Ensure the package is correctly `require`d: `const hh = require('http-https');`. If in an ESM context, consider this package incompatible and use a modern alternative.
Error: write after end
Attempting to write to or end a request multiple times, a common mistake when dealing with Node.js's native `http`/`https` modules that this wrapper exposes directly.
fix
Ensure `req.end()` is called exactly once after all data has been written to the request body, and avoid attempting to write to the request after `req.end()` has been invoked.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
http-https — npm install http-https · libregistry