(t *testing.T)
| 309 | } |
| 310 | |
| 311 | func TestDialRedirect(t *testing.T) { |
| 312 | t.Parallel() |
| 313 | |
| 314 | ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) |
| 315 | defer cancel() |
| 316 | |
| 317 | _, _, err := websocket.Dial(ctx, "ws://example.com", &websocket.DialOptions{ |
| 318 | HTTPClient: mockHTTPClient(func(r *http.Request) (*http.Response, error) { |
| 319 | resp := &http.Response{ |
| 320 | Header: http.Header{}, |
| 321 | } |
| 322 | if r.URL.Scheme != "https" { |
| 323 | resp.Header.Set("Location", "wss://example.com") |
| 324 | resp.StatusCode = http.StatusFound |
| 325 | return resp, nil |
| 326 | } |
| 327 | resp.Header.Set("Connection", "Upgrade") |
| 328 | resp.Header.Set("Upgrade", "meow") |
| 329 | resp.StatusCode = http.StatusSwitchingProtocols |
| 330 | return resp, nil |
| 331 | }), |
| 332 | }) |
| 333 | assert.Contains(t, err, "failed to WebSocket dial: WebSocket protocol violation: Upgrade header \"meow\" does not contain websocket") |
| 334 | } |
| 335 | |
| 336 | type forwardProxy struct { |
| 337 | hc *http.Client |
nothing calls this directly
no test coverage detected
searching dependent graphs…