From 9af22f64989f4288f52f61d7b81229ce91b9654d Mon Sep 17 00:00:00 2001 From: dingjun Date: Fri, 23 Dec 2016 14:09:30 +0800 Subject: [PATCH] not touch the path in proxy --- proxy.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/proxy.go b/proxy.go index 2ae99a2..4bd3d82 100644 --- a/proxy.go +++ b/proxy.go @@ -5,11 +5,11 @@ import ( "net" "net/http" //"bufio" + //"fmt" "io" "log" - "strings" - "time" //"strings" + "time" ) type proxy struct { @@ -34,7 +34,8 @@ func newProxy(addr string, prefix string) *proxy { return p } -func (p *proxy) dialContext(ctx context.Context, network, addr string) (net.Conn, error) { +func (p *proxy) dialContext(ctx context.Context, + network, addr string) (net.Conn, error) { return p.dialer.DialContext(ctx, network, p.addr) } @@ -45,10 +46,8 @@ func (p *proxy) dial(network, addr string) (conn net.Conn, err error) { func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { host, _, _ := net.SplitHostPort(r.RemoteAddr) r.Header.Add("X-Forwarded-For", host) - r.RequestURI = strings.TrimLeft(r.RequestURI, p.prefix) - //r.URL.Scheme = "http" - //r.URL.Host = r.Host - r.URL.Path = strings.TrimLeft(r.URL.Path, p.prefix) + r.URL.Scheme = "http" + r.URL.Host = r.Host resp, err := p.transport.RoundTrip(r) if err != nil { log.Print(err)