elazarl / goproxy

An HTTP proxy library for Go
BSD 3-Clause "New" or "Revised" License
6.06k stars 1.1k forks source link

CONNECT response headers #421

Open alaingilbert opened 3 years ago

alaingilbert commented 3 years ago

I'm using a MITM proxy that itself connect to another proxy and I'm trying to get the response headers received from the CONNECT request.

I currently set the proxy transport in the proxy.OnRequest().HandleConnectFunc(...) But I would need something like proxy.OnResponse().HandleConnectFunc(...) to get the response headers.

Is there any way to do this ?


proxyServer.OnRequest().HandleConnectFunc(func(host string, ctx *goproxy.ProxyCtx) (*goproxy.ConnectAction, string) {
  proxyServer.Tr = &http.Transport{
    Proxy:           http.ProxyURL(proxyUrl),
    TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  }
  return goproxy.MitmConnect, host
})