MCPcopy
hub / github.com/coder/websocket / TestDialViaProxy

Function TestDialViaProxy

dial_test.go:389–418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

387}
388
389func TestDialViaProxy(t *testing.T) {
390 t.Parallel()
391
392 ps := httptest.NewServer(newForwardProxy())
393 defer ps.Close()
394
395 s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
396 err := echoServer(w, r, nil)
397 assert.Success(t, err)
398 }))
399 defer s.Close()
400
401 psu, err := url.Parse(ps.URL)
402 assert.Success(t, err)
403 proxyTransport := http.DefaultTransport.(*http.Transport).Clone()
404 proxyTransport.Proxy = http.ProxyURL(psu)
405
406 ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
407 defer cancel()
408 c, resp, err := websocket.Dial(ctx, s.URL, &websocket.DialOptions{
409 HTTPClient: &http.Client{
410 Transport: proxyTransport,
411 },
412 })
413 assert.Success(t, err)
414 assert.Equal(t, "", "true", resp.Header.Get("PROXIED"))
415
416 assertEcho(t, ctx, c)
417 assertClose(t, c)
418}

Callers

nothing calls this directly

Calls 8

SuccessFunction · 0.92
DialFunction · 0.92
EqualFunction · 0.92
newForwardProxyFunction · 0.85
assertEchoFunction · 0.85
assertCloseFunction · 0.85
echoServerFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…