Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retry not reset multipartField reader #953

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
if err := resetFileReaders(resp.Request.multipartFiles); err != nil {
return err
}
if err := resetFieldReaders(resp.Request.multipartFields); err != nil {
return err
}

Check warning on line 144 in retry.go

View check run for this annotation

Codecov / codecov/patch

retry.go#L143-L144

Added lines #L143 - L144 were not covered by tests
}

for _, hook := range opts.retryHooks {
Expand Down Expand Up @@ -250,3 +253,15 @@

return nil
}

func resetFieldReaders(fields []*MultipartField) error {
for _, f := range fields {
if rs, ok := f.Reader.(io.ReadSeeker); ok {
if _, err := rs.Seek(0, io.SeekStart); err != nil {
return err
}

Check warning on line 262 in retry.go

View check run for this annotation

Codecov / codecov/patch

retry.go#L259-L262

Added lines #L259 - L262 were not covered by tests
}
}

return nil
}
Loading