From 4af0c1d9022058e1bf9f9725bc90be395015a051 Mon Sep 17 00:00:00 2001
From: Paul <devnoname120@gmail.com>
Date: Fri, 20 May 2022 11:04:36 +0200
Subject: [PATCH] rest: add optional GetBody function for HTTP call

---
 lib/rest/rest.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/rest/rest.go b/lib/rest/rest.go
index b5f575ce7..7303ec184 100644
--- a/lib/rest/rest.go
+++ b/lib/rest/rest.go
@@ -130,7 +130,8 @@ type Opts struct {
 	Path                  string // relative to RootURL
 	RootURL               string // override RootURL passed into SetRoot()
 	Body                  io.Reader
-	NoResponse            bool // set to close Body
+	GetBody               func() (io.ReadCloser, error) // body builder, needed to enable low-level HTTP/2 retries
+	NoResponse            bool                          // set to close Body
 	ContentType           string
 	ContentLength         *int64
 	ContentRange          string
@@ -239,6 +240,9 @@ func (api *Client) Call(ctx context.Context, opts *Opts) (resp *http.Response, e
 	if len(opts.TransferEncoding) != 0 {
 		req.TransferEncoding = opts.TransferEncoding
 	}
+	if opts.GetBody != nil {
+		req.GetBody = opts.GetBody
+	}
 	if opts.Trailer != nil {
 		req.Trailer = *opts.Trailer
 	}