HETZNER: fix retry of POST/PUT requests -- rebuild request body
Previously for any retry the request body was already consumed and
the server received an empty body.
@@ -157,6 +157,7 @@ func (api *hetznerProvider) getZone(name string) (*zone, error) {
}
func (api *hetznerProvider) request(endpoint string, method string, request interface{}, target interface{}) error {
+ for {
var requestBody io.Reader
if request != nil {
requestBodySerialised, err := json.Marshal(request)
@@ -171,7 +172,6 @@ func (api *hetznerProvider) request(endpoint string, method string, request inte
}
req.Header.Add("Auth-API-Token", api.apiKey)
- for {
api.requestRateLimiter.beforeRequest()
resp, err := http.DefaultClient.Do(req)
api.requestRateLimiter.afterRequest()
