Skip to content

Commit 07c4ce2

Browse files
authored
send the body on each http.Request retry (#1394)
1 parent 37ac451 commit 07c4ce2

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

schemaregistry/internal/rest_service.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,24 +378,29 @@ func (rs *RestService) HandleHTTPRequest(url *url.URL, request *API) (*http.Resp
378378
return nil, err
379379
}
380380

381-
var readCloser io.ReadCloser
381+
var outbuf []byte
382382
if request.body != nil {
383-
outbuf, err := json.Marshal(request.body)
383+
outbuf, err = json.Marshal(request.body)
384384
if err != nil {
385385
return nil, err
386386
}
387-
readCloser = ioutil.NopCloser(bytes.NewBuffer(outbuf))
388-
}
389-
390-
req := &http.Request{
391-
Method: request.method,
392-
URL: endpoint,
393-
Body: readCloser,
394-
Header: rs.headers,
395387
}
396388

397389
var resp *http.Response
398390
for i := 0; i < rs.maxRetries+1; i++ {
391+
392+
var readCloser io.ReadCloser
393+
if outbuf != nil {
394+
readCloser = ioutil.NopCloser(bytes.NewBuffer(outbuf))
395+
}
396+
397+
req := &http.Request{
398+
Method: request.method,
399+
URL: endpoint,
400+
Body: readCloser,
401+
Header: rs.headers,
402+
}
403+
399404
resp, err = rs.Do(req)
400405
if err != nil {
401406
return nil, err

0 commit comments

Comments
 (0)