Skip to content

Commit

Permalink
Fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPelli committed Dec 23, 2024
1 parent bbea975 commit 8503c0a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,15 @@ func TestGoproxyHijackConnect(t *testing.T) {
proxy.OnRequest(goproxy.ReqHostIs(srv.Listener.Addr().String())).
HijackConnect(func(req *http.Request, client net.Conn, ctx *goproxy.ProxyCtx) {
t.Logf("URL %+#v\nSTR %s", req.URL, req.URL.String())
req.URL.Scheme = "http"
req.URL.Path = "/bobo"
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, req.URL.String(), nil)
getReq, err := http.NewRequestWithContext(req.Context(), http.MethodGet, (&url.URL{
Scheme: "http",
Host: req.URL.Host,
Path: "/bobo",
}).String(), nil)
if err != nil {
t.Fatal("Cannot create request", err)
}
resp, err := http.DefaultClient.Do(req)
resp, err := http.DefaultClient.Do(getReq)
panicOnErr(err, "http.Get(CONNECT url)")
panicOnErr(resp.Write(client), "resp.Write(client)")
_ = resp.Body.Close()
Expand Down

0 comments on commit 8503c0a

Please sign in to comment.