@@ -67,6 +67,7 @@ type Request struct {
6767 clientTrace * clientTrace
6868 multipartFiles []* File
6969 multipartFields []* MultipartField
70+ retryConditions []RetryConditionFunc
7071}
7172
7273// Context method returns the Context if its already set in request
@@ -593,6 +594,16 @@ func (r *Request) SetCookies(rs []*http.Cookie) *Request {
593594 return r
594595}
595596
597+ // AddRetryCondition method adds a retry condition function to the request's
598+ // array of functions that are checked to determine if the request is retried.
599+ // The request will retry if any of the functions return true and error is nil.
600+ //
601+ // Note: These retry conditions are checked before all retry conditions of the client.
602+ func (r * Request ) AddRetryCondition (condition RetryConditionFunc ) * Request {
603+ r .retryConditions = append (r .retryConditions , condition )
604+ return r
605+ }
606+
596607//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
597608// HTTP request tracing
598609//_______________________________________________________________________
@@ -763,7 +774,7 @@ func (r *Request) Execute(method, url string) (*Response, error) {
763774 Retries (r .client .RetryCount ),
764775 WaitTime (r .client .RetryWaitTime ),
765776 MaxWaitTime (r .client .RetryMaxWaitTime ),
766- RetryConditions (r . client .RetryConditions ),
777+ RetryConditions (append ( r . retryConditions , r . client .RetryConditions ... ) ),
767778 RetryHooks (r .client .RetryHooks ),
768779 )
769780
0 commit comments