Skip to content

Commit

Permalink
Added reader seek start for multipart files on request retry
Browse files Browse the repository at this point in the history
  • Loading branch information
nikplxjt committed Jun 15, 2022
1 parent 3d08b36 commit ee3cd94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/go-resty/resty/v2

require golang.org/x/net v0.0.0-20211029224645-99673261e6eb
require golang.org/x/net v0.0.0-20220325170049-de3da57026de

go 1.11
7 changes: 1 addition & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/net v0.0.0-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9 changes: 9 additions & 0 deletions retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package resty

import (
"context"
"io"
"math"
"math/rand"
"sync"
Expand Down Expand Up @@ -125,6 +126,14 @@ func Backoff(operation func() (*Response, error), options ...Option) error {
return err
}

for _, f := range resp.Request.multipartFiles {
if rs, ok := f.Reader.(io.ReadSeeker); ok {
if _, err := rs.Seek(0, io.SeekStart); err != nil {
return err
}
}
}

for _, hook := range opts.retryHooks {
hook(resp, err)
}
Expand Down

0 comments on commit ee3cd94

Please sign in to comment.