Skip to content

Commit 649da25

Browse files
authored
Expose AlreadyRequested flag in HTTP details of last run (#18)
1 parent 7149880 commit 649da25

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

client.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ type Client struct {
4141
resp *http.Response
4242
respBody []byte
4343

44-
attempt int
45-
retryDelays []time.Duration
44+
alreadyRequested bool
45+
attempt int
46+
retryDelays []time.Duration
4647

4748
reqHeaders map[string]string
4849
reqCookies map[string]string
@@ -129,8 +130,9 @@ type HTTPValue struct {
129130
OtherResp *http.Response
130131
OtherRespBody []byte
131132

132-
Attempt int
133-
RetryDelays []time.Duration
133+
AlreadyRequested bool
134+
Attempt int
135+
RetryDelays []time.Duration
134136
}
135137

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

148-
Attempt: c.attempt,
149-
RetryDelays: c.retryDelays,
150+
AlreadyRequested: c.alreadyRequested,
151+
Attempt: c.attempt,
152+
RetryDelays: c.retryDelays,
150153
}
151154
}
152155

@@ -185,6 +188,7 @@ func (c *Client) Reset() *Client {
185188
c.otherRespBody = nil
186189
c.otherRespExpected = false
187190

191+
c.alreadyRequested = false
188192
c.attempt = 0
189193
c.retryDelays = nil
190194

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

375379
func (c *Client) expectResp(check func() error) (err error) {
376380
if c.resp != nil {
381+
c.alreadyRequested = true
382+
377383
return check()
378384
}
379385

0 commit comments

Comments
 (0)