fix(common.http): Keep timeout after creating oauth client (#15900)
This commit is contained in:
parent
253a114622
commit
d77cf92d6c
|
|
@ -54,16 +54,12 @@ func (h *HTTPClientConfig) CreateClient(ctx context.Context, log telegraf.Logger
|
||||||
// Register "http+unix" and "https+unix" protocol handler.
|
// Register "http+unix" and "https+unix" protocol handler.
|
||||||
unixtransport.Register(transport)
|
unixtransport.Register(transport)
|
||||||
|
|
||||||
timeout := h.Timeout
|
|
||||||
if timeout == 0 {
|
|
||||||
timeout = config.Duration(time.Second * 5)
|
|
||||||
}
|
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Transport: transport,
|
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)
|
client = h.OAuth2Config.CreateOauth2Client(ctx, client)
|
||||||
|
|
||||||
if h.CookieAuthConfig.URL != "" {
|
if h.CookieAuthConfig.URL != "" {
|
||||||
|
|
@ -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
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue