(ctx context.Context, path string, opts *websocket.DialOptions)
| 364 | } |
| 365 | |
| 366 | func (c *Client) Dial(ctx context.Context, path string, opts *websocket.DialOptions) (*websocket.Conn, error) { |
| 367 | u, err := c.URL.Parse(path) |
| 368 | if err != nil { |
| 369 | return nil, err |
| 370 | } |
| 371 | |
| 372 | if opts == nil { |
| 373 | opts = &websocket.DialOptions{} |
| 374 | } |
| 375 | // Propagate the client's HTTP client to the websocket dialer |
| 376 | // so that custom TLS configurations (e.g. mesh TLS between |
| 377 | // replicas) are used for the handshake request. Without this, |
| 378 | // the websocket library falls back to http.DefaultClient. |
| 379 | if opts.HTTPClient == nil { |
| 380 | opts.HTTPClient = c.HTTPClient |
| 381 | } |
| 382 | c.SessionTokenProvider.SetDialOption(opts) |
| 383 | |
| 384 | conn, resp, err := websocket.Dial(ctx, u.String(), opts) |
| 385 | if resp != nil && resp.Body != nil { |
| 386 | resp.Body.Close() |
| 387 | } |
| 388 | if err != nil { |
| 389 | return nil, err |
| 390 | } |
| 391 | |
| 392 | return conn, nil |
| 393 | } |
| 394 | |
| 395 | // ExpectJSONMime is a helper function that will assert the content type |
| 396 | // of the response is application/json. |
no test coverage detected