API Reference

<http-transaction>

Displays a complete HTTP request/response pair side by side. This is the main component for showing HTTP exchanges.

Attributes

AttributeTypeDescription
themestringColor theme: "light", "dark", or "auto" (default)
highlightstringComma-separated sections to highlight: request-line, request-headers, request-body, response-line, response-headers, response-body
boxstringComma-separated sections to add labeled borders: same values as highlight

Properties

PropertyTypeDescription
data Object HTTP exchange data with structure: { request: { method: string, url: string, httpVersion?: string, headers?: Object, body?: string }, response: { status: number, statusText: string, httpVersion?: string, headers?: Object, body?: string } }

CSS Custom Properties

PropertyDefaultDescription
--bg-primary#f5f5f5Primary background color
--bg-secondarywhiteSecondary background color
--border-color#dddBorder color
--text-primary#1f2937Primary text color

<http-request>

Displays just the HTTP request portion: method, URL, headers, and body.

Attributes

AttributeTypeDescription
themestringColor theme: "light", "dark", or "auto"
highlightstringSections to highlight: request-line, headers, body, or header:name
boxstringSections to add labeled borders
show-headerbooleanShow/hide the "Request" header bar (default: true)

Properties

PropertyTypeDescription
data Object Request data: { method: string, url: string, httpVersion?: string, headers?: Object, body?: string }

<http-response>

Displays just the HTTP response portion: status line, headers, and body.

Attributes

AttributeTypeDescription
themestringColor theme: "light", "dark", or "auto"
highlightstringSections to highlight: status-line, headers, body, or header:name
boxstringSections to add labeled borders
show-headerbooleanShow/hide the "Response" header bar (default: true)

Properties

PropertyTypeDescription
data Object Response data: { status: number, statusText: string, httpVersion?: string, headers?: Object, body?: string }

<http-waterfall>

Visualizes multiple HTTP exchanges with list, duration, and waterfall timeline views. Supports live capture and a built-in request builder.

Attributes

AttributeTypeDescription
viewstringView mode: "list", "duration", or "waterfall"
themestringColor theme: "light", "dark", or "auto"
capturebooleanEnable live capture of fetch/XHR requests
filterstringURL pattern filter for capture (supports * wildcards)
max-entriesnumberMaximum number of entries to display (default: 100)
explorerbooleanShow the request builder panel

Properties

PropertyTypeDescription
exchanges Array Array of HTTP exchanges with timing: [{ request: { method, url, headers, body }, response: { status, statusText, headers, body }, timing: { startTime, endTime, duration } }]
viewstringGet/set current view mode

Events

EventDetailDescription
request-sent{ method, url, headers, body }Fired when explorer sends a request
response-received{ request, response, timing }Fired when explorer receives a response
request-error{ error }Fired when explorer request fails

Methods

MethodDescription
startCapture()Start capturing HTTP requests
stopCapture()Stop capturing
togglePause()Pause/resume capturing
clearExchanges()Clear all captured exchanges
toggleExplorer()Open/close the request builder panel

HTTPInterceptor (Utility Class)

A utility class for intercepting fetch() and XMLHttpRequest calls. Used internally by http-waterfall but can be used standalone.

Usage

import { HTTPInterceptor } from '@profpowell/http-component/http-interceptor'; const interceptor = new HTTPInterceptor(); interceptor.start((exchange) => { console.log('Captured:', exchange.request.method, exchange.request.url); }, { filter: '/api/*', maxBodySize: 1024 * 1024 }); // Later, stop intercepting interceptor.stop();

Methods

MethodDescription
start(callback, options)Start intercepting with callback and options
stop()Stop intercepting and restore original functions
pause()Pause forwarding to listeners
resume()Resume forwarding to listeners
addListener(callback)Add additional listener
removeListener(callback)Remove a listener

Options

OptionTypeDefaultDescription
filterstringnullURL pattern filter (* wildcard supported)
maxBodySizenumber1MBMaximum body size to capture