MCPcopy
hub / github.com/gorilla/websocket / TestProxyDial

Function TestProxyDial

client_server_test.go:151–187  ·  client_server_test.go::TestProxyDial
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestProxyDial(t *testing.T) {
152
153 s := newServer(t)
154 defer s.Close()
155
156 surl, _ := url.Parse(s.Server.URL)
157
158 cstDialer := cstDialer // make local copy for modification on next line.
159 cstDialer.Proxy = http.ProxyURL(surl)
160
161 connect := false
162 origHandler := s.Server.Config.Handler
163
164 // Capture the request Host header.
165 s.Server.Config.Handler = http.HandlerFunc(
166 func(w http.ResponseWriter, r *http.Request) {
167 if r.Method == http.MethodConnect {
168 connect = true
169 w.WriteHeader(http.StatusOK)
170 return
171 }
172
173 if !connect {
174 t.Log("connect not received")
175 http.Error(w, "connect not received", http.StatusMethodNotAllowed)
176 return
177 }
178 origHandler.ServeHTTP(w, r)
179 })
180
181 ws, _, err := cstDialer.Dial(s.URL, nil)
182 if err != nil {
183 t.Fatalf("Dial: %v", err)
184 }
185 defer ws.Close()
186 sendRecv(t, ws)
187}
188
189func TestProxyAuthorizationDial(t *testing.T) {
190 s := newServer(t)

Callers

nothing calls this directly

Calls 6

newServerFunction · 0.85
sendRecvFunction · 0.85
ServeHTTPMethod · 0.80
DialMethod · 0.65
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected