main
1package snapshot
2
3import (
4 "net/http"
5 "time"
6)
7
8// Request captures the details of a request in attempt to Capture
9type Request struct {
10 Method string `json:"method"`
11 URL string `json:"url"`
12 Started time.Time `json:"started"`
13
14 Headers http.Header `json:"headers,omitempty"`
15 UserAgent string `json:"user_agent,omitempty"`
16 TimeoutMS int64 `json:"timeout_ms,omitempty"`
17}
18
19// Result is the details of a Capture attempt
20type Result struct {
21 OK bool `json:"ok"`
22 StatusCode int `json:"status_code,omitempty"`
23 FinalURL string `json:"final_url,omitempty"`
24 BodyPath string `json:"body_path,omitempty"`
25
26 Request Request `json:"request"`
27 Failure *Failure `json:"failure,omitempty"`
28}
29
30// Failure records the details of failed Capture attempt
31type Failure struct {
32 Stage Stage `json:"stage"`
33 Error string `json:"error"`
34 Transient bool `json:"transient,omitempty"`
35}
36
37type Stage string
38
39const (
40 _do_request Stage = "do_request"
41 _http_status Stage = "http_status"
42 _body_open Stage = "body_open"
43 _body_write Stage = "body_write"
44 _body_commit Stage = "body_commit"
45)