har

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package har imports HTTP Archive (HAR) files as Pulse scenarios. HAR files can be exported from browser DevTools (Network tab → Save as HAR). Each recorded request becomes a named step in a pulse.Flow, replayed in the order they appear in the archive.

WARNING: HAR files often contain authentication headers and session tokens. Treat them as sensitive — do not commit them to version control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(r io.Reader, cfg Config) (pulse.Scenario, error)

Load parses HAR data from r and returns a Scenario that replays all included requests in sequence using pulse.Flow. Each step is named "<METHOD> <URL>" so failures are identifiable in the result error map.

Hop-by-hop headers (Host, Content-Length, etc.) are stripped. All other recorded headers, including Authorization, are forwarded as-is.

func LoadFile

func LoadFile(path string, cfg Config) (pulse.Scenario, error)

LoadFile parses a HAR file at path and returns a Scenario that replays all included requests in sequence. See Load for details.

Types

type Config

type Config struct {
	// Filter, when non-nil, is called for each entry. Return false to skip it.
	// Use this to exclude static assets, analytics beacons, or third-party requests.
	Filter func(req Request) bool
	// Client is the HTTP client used to replay requests.
	// When nil, a client with a 30 s timeout is used.
	Client *http.Client
}

Config controls how HAR entries are imported.

type Entry

type Entry struct {
	Request Request `json:"request"`
}

Entry represents a single recorded HTTP transaction.

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Header is a name/value pair.

type PostData

type PostData struct {
	MimeType string `json:"mimeType"`
	Text     string `json:"text"`
}

PostData holds the request body recorded in the HAR.

type Request

type Request struct {
	Method   string   `json:"method"`
	URL      string   `json:"url"`
	Headers  []Header `json:"headers"`
	PostData PostData `json:"postData"`
}

Request holds the recorded HTTP request data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL