Skip to content

Commit

Permalink
Merge pull request #216 from jkawamoto/215
Browse files Browse the repository at this point in the history
Stop preparing the request if an error occurs
  • Loading branch information
casualjim committed Sep 9, 2021
2 parents 715c788 + b3931df commit 2bc043c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/request.go
Expand Up @@ -139,6 +139,7 @@ func (r *request) buildHTTP(mediaType, basePath string, producers map[string]run
if err := mp.WriteField(fn, vi); err != nil {
pw.CloseWithError(err)
log.Println(err)
return
}
}
}
Expand All @@ -158,6 +159,7 @@ func (r *request) buildHTTP(mediaType, basePath string, producers map[string]run
if err != nil {
_ = pw.CloseWithError(err)
log.Println(err)
return
}
fileContentType := http.DetectContentType(buf)
newFi := runtime.NamedReader(fi.Name(), io.MultiReader(bytes.NewReader(buf[:size]), fi))
Expand All @@ -173,7 +175,9 @@ func (r *request) buildHTTP(mediaType, basePath string, producers map[string]run
if err != nil {
pw.CloseWithError(err)
log.Println(err)
} else if _, err := io.Copy(wrtr, newFi); err != nil {
return
}
if _, err := io.Copy(wrtr, newFi); err != nil {
pw.CloseWithError(err)
log.Println(err)
}
Expand Down

0 comments on commit 2bc043c

Please sign in to comment.