http-debug: Simple HTTP(S) Debugger

0.1.2 · abandoned · verified Wed Apr 22

http-debug is a lightweight utility designed to provide verbose debugging output for Node.js `http` and `https` requests. It operates by patching Node's built-in `http` and `https` modules to intercept and log request, write, end, and socket events to `stderr`. The current stable version is `0.1.2`. Given its low version number and the age of the provided changelog, the project appears to have a very slow or effectively ceased release cadence, last updated around 2013-2014. Its primary differentiator is its simplicity and direct global patching approach, allowing for debugging without modifying application code for each request, though this can lead to conflicts. It supports enabling debugging via `process.env.HTTP_DEBUG` or by setting `http.debug` at runtime, offering different verbosity levels.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and enable verbose HTTP request debugging using http-debug, then makes a sample HTTP GET request to observe the detailed output on stderr.

const httpDebug = require('http-debug');
const http = httpDebug.http;

// Set debugging level to verbose (2).
// 0: off, 1: on (request, write, end), 2: verbose (on + error, socket events)
http.debug = 2;

// Alternatively, set via environment variable before running:
// process.env.HTTP_DEBUG = '2';

console.log('Making an HTTP GET request to mervine.net...');
console.log('Debug output will appear on stderr.');

http.get('http://mervine.net/', (res) => {
   let data = '';
   res.on('data', (chunk) => { data += chunk; });
   res.on('end', () => {
      console.log(`\nHTTP Response Status Code: ${res.statusCode}`);
      console.log(`Content length: ${data.length} bytes`);
   });
}).on('error', (err) => {
   console.error('Error during HTTP request:', err.message);
});

// Example for HTTPS (uncomment to use)
// const https = httpDebug.https;
// https.debug = 2;
// https.get('https://example.com/', (res) => {
//    // ... handle response ...
// }).on('error', (err) => {
//    console.error('Error during HTTPS request:', err.message);
// });

view raw JSON →