har

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package har provides an adapter for converting HAR (HTTP Archive) files to IR format.

HAR is a standard format for recording HTTP transactions, supported by:

  • Browser DevTools (Chrome, Firefox, Safari)
  • Playwright and Puppeteer
  • Charles Proxy, Fiddler, mitmproxy
  • Postman

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntryCount

func EntryCount(path string) (int, error)

EntryCount returns the number of entries in a HAR file without fully parsing.

func FilterByContentType

func FilterByContentType(h *har.HAR, contentType string) []*har.Entry

FilterByContentType returns entries with responses matching the content type.

func FilterByHost

func FilterByHost(h *har.HAR, host string) []*har.Entry

FilterByHost returns entries matching the given host.

func FilterByMethod

func FilterByMethod(h *har.HAR, method string) []*har.Entry

FilterByMethod returns entries matching the given HTTP method.

func FilterByStatus

func FilterByStatus(h *har.HAR, status int) []*har.Entry

FilterByStatus returns entries matching the given status code.

func FilterEntries

func FilterEntries(h *har.HAR, predicate func(*har.Entry) bool) []*har.Entry

FilterEntries filters HAR entries based on a predicate function.

func Parse

func Parse(data []byte) (*har.HAR, error)

Parse parses HAR JSON data into a HAR struct.

func ParseFile

func ParseFile(path string) (*har.HAR, error)

ParseFile parses a HAR file into a HAR struct.

Types

type Converter

type Converter struct {
	// IncludeHeaders controls whether to include HTTP headers in output.
	IncludeHeaders bool

	// FilterHeaders is a list of header names to exclude (case-insensitive).
	FilterHeaders []string

	// IncludeCookies controls whether to include cookies in headers.
	IncludeCookies bool
}

Converter converts HAR entries to IR records.

func NewConverter

func NewConverter() *Converter

NewConverter creates a new HAR to IR converter with default settings.

func (*Converter) Convert

func (c *Converter) Convert(entry *har.Entry) *ir.IRRecord

Convert converts a single HAR entry to an IR record.

func (*Converter) ConvertBatch

func (c *Converter) ConvertBatch(entries []*har.Entry) []ir.IRRecord

ConvertBatch converts multiple HAR entries to IR records.

func (*Converter) ConvertHAR

func (c *Converter) ConvertHAR(h *har.HAR) []ir.IRRecord

ConvertHAR converts a complete HAR file to IR records.

type Reader

type Reader struct {
	Converter *Converter
}

Reader reads HAR files and converts them to IR format.

func NewReader

func NewReader() *Reader

NewReader creates a new HAR reader with default settings.

func (*Reader) Read

func (r *Reader) Read(reader io.Reader) ([]ir.IRRecord, error)

Read reads HAR data from an io.Reader and returns IR records.

func (*Reader) ReadDir

func (r *Reader) ReadDir(path string) ([]ir.IRRecord, error)

ReadDir reads all HAR files from a directory and returns IR records.

func (*Reader) ReadFile

func (r *Reader) ReadFile(path string) ([]ir.IRRecord, error)

ReadFile reads a HAR file and returns IR records.

Jump to

Keyboard shortcuts

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