Skip to content

Commit

Permalink
Document issue with original documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Dohnálek <dohnto@gmail.com>
  • Loading branch information
dohnto committed Apr 12, 2022
1 parent 7016fd3 commit ebe4b5b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/prometheus/v1/api.go
Expand Up @@ -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)
Expand Down

0 comments on commit ebe4b5b

Please sign in to comment.