{"id":16066,"library":"http-https","title":"HTTP/HTTPS Request Wrapper","description":"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.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/isaacs/http-https","tags":["javascript"],"install":[{"cmd":"npm install http-https","lang":"bash","label":"npm"},{"cmd":"yarn add http-https","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-https","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not provide an ESM export. Use `require`.","wrong":"import hh from 'http-https'","symbol":"hh","correct":"const hh = require('http-https')"},{"note":"The primary API is the `request` method, accessed as a property of the main export.","wrong":"import { request } from 'http-https'","symbol":"request","correct":"const { request } = require('http-https')"},{"note":"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.","wrong":"new URL('...').href","symbol":"url.parse","correct":"const url = require('url'); url.parse('...')"}],"quickstart":{"code":"const hh = require('http-https');\nconst url = require('url'); // Node.js built-in url module\n\n// Example 1: Direct URL string\nconst simpleReq = hh.request('http://example.com/bar', (res) => {\n  console.log(`HTTP Status: ${res.statusCode}`);\n  res.setEncoding('utf8');\n  let rawData = '';\n  res.on('data', (chunk) => { rawData += chunk; });\n  res.on('end', () => {\n    console.log('Simple HTTP Response received.');\n  });\n});\nsimpleReq.on('error', (e) => console.error(`Simple request error: ${e.message}`));\nsimpleReq.end();\n\n// Example 2: With parsed URL object and custom headers\nconst someUrlMaybeHttpMaybeHttps = 'https://secure.example.com/foo';\nconst parsedOpt = url.parse(someUrlMaybeHttpMaybeHttps);\nparsedOpt.headers = {\n  'User-Agent': 'flergy mc flerg/1.0'\n};\nparsedOpt.method = 'GET'; // Changed to GET for typical fetch\n\nconst secureReq = hh.request(parsedOpt, (res) => {\n  console.log(`HTTPS Status: ${res.statusCode}, Headers: ${JSON.stringify(res.headers)}`);\n  res.setEncoding('utf8');\n  let rawData = '';\n  res.on('data', (chunk) => { rawData += chunk; });\n  res.on('end', () => {\n    console.log('Secure HTTPS Response received.');\n  });\n});\nsecureReq.on('error', (e) => console.error(`Secure request error: ${e.message}`));\nsecureReq.end();","lang":"javascript","description":"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)."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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`.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"Attempting to use `hh.request` when `http-https` was imported incorrectly or when `require` returns `undefined`.","error":"TypeError: hh.request is not a function"},{"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.","cause":"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.","error":"Error: write after end"}],"ecosystem":"npm"}