cURL Trace Parser

0.0.10 · abandoned · verified Wed Apr 22

curl-trace-parser is a Node.js package designed to parse the output generated by the `curl` command-line tool when using its `--trace` or `--trace-ascii` options. It extracts raw HTTP request and response messages from curl's custom trace format, which otherwise presents data in fragmented chunks. This utility is particularly useful for debugging or introspecting HTTP communication of RESTful APIs without resorting to lower-level tools like tcpdump or Wireshark. It offers output in a raw HTTP message format or an API Blueprint format. The package is at version 0.0.10 and appears to be abandoned, with no recent updates or a clear release cadence. Its key differentiator is simplifying the often complex task of interpreting curl's trace output into structured HTTP messages.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates programmatic usage of `curl-trace-parser` by reading a mock trace file, feeding its lines to the parser's `execute` method, listening for 'request' and 'response' events, and piping the parser's transformed output to a custom stream to collect the raw HTTP messages.

const fs = require('fs');
const { Writable } = require('stream');
const parser = require('curl-trace-parser');

// Simulate curl --trace output from a file
const traceData = fs.readFileSync('trace.log', 'utf8');

// Create a custom writable stream to capture parsed output
let rawOutput = '';
const customWriter = new Writable({
  write(chunk, encoding, callback) {
    rawOutput += chunk.toString();
    callback();
  }
});

// Pipe the parser's raw output to our custom writer
parser.pipe(customWriter);

parser.on('request', (req) => {
  console.log('--- Parsed Request ---');
  // For programmatic access, you would process the 'req' object
  // The 'req' object itself might contain structured data or just the raw lines depending on internal implementation
});

parser.on('response', (res) => {
  console.log('--- Parsed Response ---');
  // For programmatic access, you would process the 'res' object
});

// Feed the trace data line by line to the parser
traceData.split('\n').forEach(line => {
  parser.execute(line);
});

parser.end(); // Signal end of input

// After processing all lines, the rawOutput will contain the parsed HTTP messages
console.log('\n--- Raw HTTP Output from Parser Stream ---');
console.log(rawOutput);

view raw JSON →