har

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package har turns a HAR file (the recording a browser's network tab can save) into a VegaLoad JavaScript scenario. It is for the first draft of a scenario: record a real session in the browser, import it, then edit the file.

What the importer does to a recording:

  • It drops what a load test should not repeat: images, fonts, style sheets and scripts; requests to other sites (analytics, ads, CDNs); CORS preflight requests; and requests that failed in the browser.
  • It keeps the secrets it can recognise out of the scenario. A Cookie or Authorization header, any header, query parameter or body field whose name looks secret, and any value that is a JWT, is read from the environment at run time (env.VL_NAME). The scenario lists the variables to pass with -secret-env. The check works on names and on the shape of a JWT. A secret with an ordinary name stays in the file as it was recorded: a token in a path such as /reset/<token>, a query parameter named code, or a field named key. Read the file before you share it, and do not commit the HAR file itself.
  • It drops headers that a client sets by itself (User-Agent, Host, Content-Length, Accept-Encoding and similar), and the headers that tie a request to the recorded page (Origin, Referer, Sec-*).
  • It marks values that look like they change on every run, such as a UUID, a long number or a token, with a TODO comment. When the same value appears in the answer to an earlier request, the comment says which request, so the author can carry the value forward.

It does not guess a flow: it keeps the recorded order and one call per request. It writes no waits between calls, because the scenario API has no sleep. It does not import WebSocket frames or multipart bodies; it says so in a TODO where that happens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Hosts keeps only requests to these hosts (a name, or name:port).
	// When empty, Convert keeps the site of the first page that the
	// recording opened (its first document request).
	Hosts []string
	// IncludeStatic keeps images, fonts, style sheets and scripts.
	IncludeStatic bool
	// IncludeThirdParty keeps requests to hosts of other sites.
	IncludeThirdParty bool
	// MaxRequests stops after this many requests. 0 means no limit.
	MaxRequests int
}

Options controls what Convert keeps.

type Result

type Result struct {
	Script   string         // the scenario file content
	Requests int            // requests in the scenario
	Total    int            // entries in the recording
	Skipped  map[string]int // why entries were left out, with counts
	Hosts    []string       // hosts the scenario calls, sorted
	EnvNames []string       // environment variables the scenario reads, sorted
	Todos    int            // TODO notes in the scenario
}

Result is the scenario and a summary of what was done.

func Convert

func Convert(r io.Reader, source string, opt Options) (*Result, error)

Convert reads a HAR file and returns a scenario.

Jump to

Keyboard shortcuts

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