Skip to content

Commit

Permalink
Expose AlreadyRequested flag in HTTP details of last run (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Oct 31, 2024
1 parent 7149880 commit 649da25
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ type Client struct {
resp *http.Response
respBody []byte

attempt int
retryDelays []time.Duration
alreadyRequested bool
attempt int
retryDelays []time.Duration

reqHeaders map[string]string
reqCookies map[string]string
Expand Down Expand Up @@ -129,8 +130,9 @@ type HTTPValue struct {
OtherResp *http.Response
OtherRespBody []byte

Attempt int
RetryDelays []time.Duration
AlreadyRequested bool
Attempt int
RetryDelays []time.Duration
}

// Details returns HTTP request and response information of last run.
Expand All @@ -145,8 +147,9 @@ func (c *Client) Details() HTTPValue {
OtherResp: c.otherResp,
OtherRespBody: c.otherRespBody,

Attempt: c.attempt,
RetryDelays: c.retryDelays,
AlreadyRequested: c.alreadyRequested,
Attempt: c.attempt,
RetryDelays: c.retryDelays,
}
}

Expand Down Expand Up @@ -185,6 +188,7 @@ func (c *Client) Reset() *Client {
c.otherRespBody = nil
c.otherRespExpected = false

c.alreadyRequested = false
c.attempt = 0
c.retryDelays = nil

Expand Down Expand Up @@ -374,6 +378,8 @@ func (c *Client) do() (err error) { //nolint:funlen

func (c *Client) expectResp(check func() error) (err error) {
if c.resp != nil {
c.alreadyRequested = true

return check()
}

Expand Down

0 comments on commit 649da25

Please sign in to comment.