From 66ac0ad9c8ff0dc67ba22af2099010514baa12aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dohn=C3=A1lek?= Date: Tue, 12 Apr 2022 22:55:05 +0200 Subject: [PATCH] Document issue with original documentation --- api/prometheus/v1/api.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/prometheus/v1/api.go b/api/prometheus/v1/api.go index e9242c845..c5e72ed1a 100644 --- a/api/prometheus/v1/api.go +++ b/api/prometheus/v1/api.go @@ -1138,8 +1138,13 @@ func (h *apiClientImpl) DoGetFallback(ctx context.Context, u *url.URL, args url. return nil, nil, nil, err } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - // Underlying `net.http` library automatically retries` idempotent requests when connectivity issues are hit. - // POST requests are not considered idempotent by default, so we need to explicitly mark them as such. + // Following comment originates from https://pkg.go.dev/net/http#Transport : + // Transport only retries a request upon encountering a network error if the request is + // idempotent and either has no body or has its Request.GetBody defined. HTTP requests + // are considered idempotent if they have HTTP methods GET, HEAD, OPTIONS, or TRACE; or + // if their Header map contains an "Idempotency-Key" or "X-Idempotency-Key" entry. If the + // idempotency key value is a zero-length slice, the request is treated as idempotent but + // the header is not sent on the wire. req.Header["Idempotency-Key"] = nil resp, body, warnings, err := h.Do(ctx, req)