Documentation
¶
Overview ¶
Package har records bounded HTTP Archive (HAR) 1.2 exchanges.
Index ¶
Constants ¶
const ( Version = "1.2" BodyOmittedComment = "Body omitted by fetch because it exceeds the 16 MiB HAR capture limit" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder reserves a HAR destination and records one final exchange. Recorder is safe for the request observer and response tee to use from different goroutines, although a fetch invocation normally has one stream.
func New ¶
New reserves path before a request starts. It does not create the final destination until Finalize commits a complete HAR document.
func (*Recorder) CaptureResponse ¶
func (r *Recorder) CaptureResponse(resp *http.Response) *ResponseCapture
CaptureResponse creates the bounded tee for resp's decoded response body.
func (*Recorder) Close ¶
Close removes an uncommitted reservation. It is safe to call after Finalize and should normally be deferred by the caller.
func (*Recorder) Finalize ¶
Finalize writes and atomically commits the one-entry HAR document. The response body must have been consumed as far as the caller intends before this method is called.
func (*Recorder) ObserveRequest ¶
ObserveRequest attaches a bounded request-body capture to req. It is meant to be used as a client request observer, so it sees initial requests, redirect requests, retries, and Digest replays.
type Request ¶
type Request struct {
Method string `json:"method"`
URL string `json:"url"`
HTTPVersion string `json:"httpVersion"`
Headers []NameValue `json:"headers"`
Cookies []Cookie `json:"cookies"`
QueryString []NameValue `json:"queryString"`
PostData *PostData `json:"postData,omitempty"`
HeadersSize int64 `json:"headersSize"`
BodySize int64 `json:"bodySize"`
}
type Response ¶
type Response struct {
Status int `json:"status"`
StatusText string `json:"statusText"`
HTTPVersion string `json:"httpVersion"`
Headers []NameValue `json:"headers"`
Cookies []Cookie `json:"cookies"`
Content Content `json:"content"`
RedirectURL string `json:"redirectURL"`
HeadersSize int64 `json:"headersSize"`
BodySize int64 `json:"bodySize"`
}
type ResponseCapture ¶
type ResponseCapture struct {
// contains filtered or unexported fields
}
ResponseCapture is an io.Writer suitable for body.Stream.AddTee.
func (*ResponseCapture) Size ¶
func (c *ResponseCapture) Size() int64
Size reports the number of decoded response bytes observed by the tee.
type Timings ¶
type Timings struct {
DNS time.Duration
Connect time.Duration
TLS time.Duration
Wait time.Duration
Receive time.Duration
TransferSize int64
TransferKnown bool
RemoteIP string
DNSKnown bool
ConnectKnown bool
TLSKnown bool
WaitKnown bool
ReceiveKnown bool
CompletedAt time.Time
}
Timings contains the measurements available from the request transport. Values are converted to HAR milliseconds when the entry is written.