package module
Version: v0.0.0-...-8f3ca3a Latest Latest

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

Go to latest
Published: Feb 28, 2017 License: MIT Imports: 16 Imported by: 0



Alternative to browsermob-proxy written in go.

Build Status


Supports creating new proxies, serving HAR logs, and remapping hosts.

  • Create proxy: POST /proxy

    • Returns : { "port": [portNumber] }
  • Get HAR: PUT /proxy/[portNumber]/har

    • Returns HAR log in json, and clears previous entries
  • Remapping hosts: POST /proxy/[portNumber]/hosts

    • Expects json containing array of : { "Host" : [oldHost], "NewHost" : [newHost] }
    • Supports IP / host name
  • Delete Proxy: DELETE /proxy/[portNumber]

Currently does not fill whole HAR - timings contain only timing between request start and response end. Also does not work with https requests yet.




This section is empty.


View Source
var Verbosity bool


func GetPort

func GetPort(l net.Listener) int

func NewProxyServer

func NewProxyServer(port int)


type Har

type Har struct {
	HarLog HarLog `json:"harLog"`

type HarContent

type HarContent struct {
	Size        int64  `json:"size"`
	Compression int64  `json:"compression"`
	MimeType    string `json:"mimeType"`
	Text        string `json:"text"`
	Encoding    string `json:"encoding"`

type HarCookie

type HarCookie struct {
	Name     string    `json:"name"`
	Value    string    `json:"value"`
	Path     string    `json:"path"`
	Domain   string    `json:"domain"`
	Expires  time.Time `json:"expires"`
	HttpOnly bool      `json:"httpOnly"`
	Secure   bool      `json:"secure"`

type HarEntry

type HarEntry struct {
	PageRef         string       `json:"pageRef"`
	StartedDateTime time.Time    `json:"startedDateTime"`
	Time            int64        `json:"time"`
	Request         *HarRequest  `json:"request"`
	Response        *HarResponse `json:"response"`
	Timings         HarTimings   `json:"timings"`
	ServerIpAddress string       `json:"serverIpAddress"`
	Connection      string       `json:"connection"`

type HarLog

type HarLog struct {
	Version string     `json:"version"`
	Creator string     `json:"creator"`
	Browser string     `json:"browser"`
	Pages   []HarPage  `json:"pages"`
	Entries []HarEntry `json:"entries"`

type HarNameValuePair

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

type HarPage

type HarPage struct {
	Id              string         `json:"id"`
	StartedDateTime time.Time      `json:"startedDateTime"`
	Title           string         `json:"title"`
	PageTimings     HarPageTimings `json:"pageTimings"`

type HarPageTimings

type HarPageTimings struct {
	OnContentLoad int64 `json:"onContentLoad"`
	OnLoad        int64 `json:"onLoad"`

type HarPostData

type HarPostData struct {
	MimeType string             `json:"mimeType"`
	Params   []HarPostDataParam `json:"params"`
	Text     string             `json:"text"`

type HarPostDataParam

type HarPostDataParam struct {
	Name        string `json:"name"`
	Value       string `json:"value"`
	FileName    string `json:"fileName"`
	ContentType string `json:"contentType`

type HarProxy

type HarProxy struct {
	// Our go proxy
	Proxy *goproxy.ProxyHttpServer

	// The port our proxy is listening on
	Port int

	// Our HAR log.
	// Starting size of 1000 entries, enlarged if necessary
	// Read the specification here: http://www.softwareishard.com/blog/har-12-spec/
	HarLog *HarLog

	// Stoppable listener - used to stop http proxy
	StoppableListener *stoppableListener
	// contains filtered or unexported fields

func NewHarProxy

func NewHarProxy() *HarProxy

func NewHarProxyWithPort

func NewHarProxyWithPort(port int) *HarProxy

func (*HarProxy) AddHostEntries

func (proxy *HarProxy) AddHostEntries(hostEntries []ProxyHosts)

func (*HarProxy) ClearEntries

func (proxy *HarProxy) ClearEntries()

func (*HarProxy) NewHarReader

func (proxy *HarProxy) NewHarReader() io.Reader

func (*HarProxy) Start

func (proxy *HarProxy) Start()

func (*HarProxy) Stop

func (proxy *HarProxy) Stop()

func (*HarProxy) WaitForEntries

func (proxy *HarProxy) WaitForEntries()

type HarRequest

type HarRequest struct {
	Method      string             `json:"method"`
	Url         string             `json:"url"`
	HttpVersion string             `json:"httpVersion"`
	Cookies     []HarCookie        `json:"cookies"`
	Headers     []HarNameValuePair `json:"headers"`
	QueryString []HarNameValuePair `json:"queryString"`
	PostData    *HarPostData       `json:"postData"`
	BodySize    int64              `json:"bodySize"`
	HeadersSize int64              `json:"headersSize"`

type HarResponse

type HarResponse struct {
	Status      int                `json:"status"`
	StatusText  string             `json:"statusText"`
	HttpVersion string             `json:"httpVersion`
	Cookies     []HarCookie        `json:"cookies"`
	Headers     []HarNameValuePair `json:"headers"`
	Content     *HarContent        `json:"content"`
	RedirectUrl string             `json:"redirectUrl"`
	BodySize    int64              `json:"bodySize"`
	HeadersSize int64              `json:"headersSize"`

type HarTimings

type HarTimings struct {
	Blocked int64
	Dns     int64
	Connect int64
	Send    int64
	Wait    int64
	Receive int64
	Ssl     int64

type ProxyHosts

type ProxyHosts struct {
	Host    string `json:"host"`
	NewHost string `json:"NewHost"`

type ProxyServerErr

type ProxyServerErr struct {
	Error string `json:"error"`

type ProxyServerMessage

type ProxyServerMessage struct {
	Message string `json:"message"`

type ProxyServerPort

type ProxyServerPort struct {
	Port int `json:"port"`


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL