goproxy
goproxy copied to clipboard
cascade example Tr.Proxy function not being invoked..
This is in reference to the cascade example: https://github.com/elazarl/goproxy/blob/master/examples/cascadeproxy/main.go
I was trying to check when the following function for Tr.Proxy() was being invoked. Adding some debug statements in that function does not seem to invoke this code.
Also, commenting out all of the code below here, does not seem to change anything. The proxy request still goes through.
Couple of questions:
- When and how should Tr.Proxy used?
- As the code is working without the below code, is there an override that is happening for Tr.Proxy
- Same for the Connect.Dial. Why did it work when it was commented out?
middleProxy.Tr.Proxy = func(req *http.Request) (*url.URL, error) {
return url.Parse("http://localhost:8082")
}
connectReqHandler := func(req *http.Request) {
SetBasicAuth(username, password, req)
}
middleProxy.ConnectDial = middleProxy.NewConnectDialToProxyWithHandler("http://localhost:8082", connectReqHandler)
middleProxy.OnRequest().Do(goproxy.FuncReqHandler(func(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
SetBasicAuth(username, password, req)
return req, nil
}))
Hi, there has a comment about the method ConnectDial:
ConnectDial will be used to create TCP connections for CONNECT requests So, you should visit destination through https instead http :)