har

package module
v0.0.0-...-4ebc53d Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 8 Imported by: 1

README

GoDoc

Read HAR ("HTTP Archive format") archives.

Use har.FromFile("path.har") to read in to a HAR struct. You can then use Extract().

See ./cmd/unhar for an example.

Install with go get arp242.net/har/cmd/unhar, which will put the binary at ~/go/bin/unhar.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	PageRef         string    `json:"pageRef"` // "page_1"
	StartedDateTime time.Time `json:"startedDateTime"`

	Request struct {
		BodySize    int    `json:"bodySize"`
		HeadersSize int    `json:"headersSize"`
		Method      string `json:"method"`
		URL         string `json:"url"`         // "http://localhost/..."
		HTTPVersion string `json:"httpVersion"` // "HTTP/1.1"
		Headers     []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"headers"`
		Cookies []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"headers"`
		QueryString []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"queryString"`
	} `json:"request"`

	Response struct {
		HeadersSize int    `json:"headersSize"`
		BodySize    int    `json:"bodySize"`
		Status      int    `json:"status"`
		StatusText  string `json:"statusText"`  // "OK"
		HTTPVersion string `json:"httpVersion"` // "HTTP/1.1"
		RedirectURL string `json:"redirectURL"`
		Headers     []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"headers"`
		Cookies []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"headers"`
		Content struct {
			Encoding string `json:"encoding"`
			Size     int    `json:"size"`
			Text     string `json:"text"`
		} `json:"content"`
	} `json:"response"`

	Cache struct {
	} `json:"cache"`

	Timings struct {
		Blocked int `json:"blocked"`
		DNS     int `json:"dns"`
		Connect int `json:"connect"`
		SSL     int `json:"ssl"`
		Send    int `json:"send"`
		Wait    int `json:"wait"`
		Receive int `json:"receive"`
	} `json:"timings"`

	Time            int    `json:"time"`
	SecurityState   string `json:"_securityState"`  // TODO
	ServerIPAddress string `json:"serverIPAddress"` // "::1"
	Connection      string `json:"connection"`      // "80"
}

type Har

type Har struct {
	File string `json:"-"` // File this was read from.

	Log struct {
		Version string `json:"version"` // "1.2"
		Creator struct {
			Name    string `json:"name"`    // "Firefox"
			Version string `json:"version"` // "72.0.2"
		} `json:"creator"`
		Browser struct {
			Name    string `json:"name"`    // "Firefox"
			Version string `json:"version"` // "72.0.2"
		} `json:"browser"`
		Pages []struct {
			StartedDateTime time.Time `json:"startedDateTime"`
			ID              string    `json:"id"` // "page_1"
			PageTimings     struct {
				OnContentLoad int `json:"onContentLoad"`
				OnLoad        int `json:"onLoad"`
			} `json:"pageTimings"`
		} `json:"pages"`

		Entries []Entry `json:"entries"`
	} `json:"log"`
}

Har archive.

func FromFile

func FromFile(f string) (*Har, error)

FromFile reads a file in to a Har struct.

func (*Har) Extract

func (h *Har) Extract(verbose bool) error

Extract all the files.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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