Skip to content

Commit

Permalink
fix(common.http): Keep timeout after creating oauth client (#15900)
Browse files Browse the repository at this point in the history
  • Loading branch information
lestrozi authored Sep 19, 2024
1 parent 253a114 commit d77cf92
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/common/http/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ func (h *HTTPClientConfig) CreateClient(ctx context.Context, log telegraf.Logger
// Register "http+unix" and "https+unix" protocol handler.
unixtransport.Register(transport)

timeout := h.Timeout
if timeout == 0 {
timeout = config.Duration(time.Second * 5)
}

client := &http.Client{
Transport: transport,
Timeout: time.Duration(timeout),
}

// While CreateOauth2Client returns a http.Client keeping the Transport configuration,
// it does not keep other http.Client parameters (e.g. Timeout).
client = h.OAuth2Config.CreateOauth2Client(ctx, client)

if h.CookieAuthConfig.URL != "" {
Expand All @@ -72,5 +68,11 @@ func (h *HTTPClientConfig) CreateClient(ctx context.Context, log telegraf.Logger
}
}

timeout := h.Timeout
if timeout == 0 {
timeout = config.Duration(time.Second * 5)
}
client.Timeout = time.Duration(timeout)

return client, nil
}

0 comments on commit d77cf92

Please sign in to comment.