Send custom headers for live queries (#8991)
This needed to be set specifically for the live query websocket dialer, since that doesn't use the HTTP client that the rest of the API client methods use. Co-authored-by: Tomas Touceda <chiiph@gmail.com>
This commit is contained in:
co-authored by
Tomas Touceda
parent
a6d3938182
commit
083b781c2c
@@ -0,0 +1 @@
|
||||
* Fix `fleetctl query` to use custom HTTP headers if configured.
|
||||
@@ -91,7 +91,12 @@ func (c *Client) LiveQueryWithContext(ctx context.Context, query string, labels
|
||||
wssURL.Scheme = "ws"
|
||||
}
|
||||
wssURL.Path = c.urlPrefix + "/api/latest/fleet/results/websocket"
|
||||
conn, _, err := dialer.Dial(wssURL.String(), nil)
|
||||
// Ensure custom headers (set by config) are added to websocket request
|
||||
headers := make(http.Header)
|
||||
for k, v := range c.customHeaders {
|
||||
headers.Set(k, v)
|
||||
}
|
||||
conn, _, err := dialer.Dial(wssURL.String(), headers)
|
||||
if err != nil {
|
||||
return nil, ctxerr.Wrap(ctx, err, "upgrade live query result websocket")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user