diff --git a/src/github.com/getlantern/enproxy/conn_impl.go b/src/github.com/getlantern/enproxy/conn_impl.go index 4a48aa8c0d..75e3c17b35 100644 --- a/src/github.com/getlantern/enproxy/conn_impl.go +++ b/src/github.com/getlantern/enproxy/conn_impl.go @@ -132,8 +132,8 @@ func (c *conn) doRequest(proxyConn *connInfo, host string, op string, request *r if request != nil { body = request.body } - fullRequest := host + "/" + c.id + "/" + c.addr + "/" + op - req, err := c.config.NewRequest(fullRequest, "POST", body) + path := c.id + "/" + c.addr + "/" + op + req, err := c.config.NewRequest(host, path, "POST", body) if err != nil { err = fmt.Errorf("Unable to construct request to %s via proxy %s: %s", c.addr, host, err) return diff --git a/src/github.com/getlantern/enproxy/conn_intf.go b/src/github.com/getlantern/enproxy/conn_intf.go index 5fe6206a11..fee8f8d4c4 100644 --- a/src/github.com/getlantern/enproxy/conn_intf.go +++ b/src/github.com/getlantern/enproxy/conn_intf.go @@ -162,7 +162,7 @@ type Config struct { type dialFunc func(addr string) (net.Conn, error) // newRequestFunc is a function that builds a new request to the upstream proxy -type newRequestFunc func(host string, method string, body io.Reader) (*http.Request, error) +type newRequestFunc func(host, path, method string, body io.Reader) (*http.Request, error) // rwResponse is a response to a read or write type rwResponse struct { diff --git a/src/github.com/getlantern/enproxy/conn_test.go b/src/github.com/getlantern/enproxy/conn_test.go index f4f96f06b8..f0d249e060 100644 --- a/src/github.com/getlantern/enproxy/conn_test.go +++ b/src/github.com/getlantern/enproxy/conn_test.go @@ -238,8 +238,8 @@ func prepareConn(addr string, buffered bool, fail bool, t *testing.T, onResponse }) } -func newRequest(host string, method string, body io.Reader) (req *http.Request, err error) { - return http.NewRequest(method, "http://"+proxyAddr, body) +func newRequest(host, path, method string, body io.Reader) (req *http.Request, err error) { + return http.NewRequest(method, "http://"+proxyAddr+"/"+path+"/", body) } func doRequests(conn net.Conn, t *testing.T) { diff --git a/src/github.com/getlantern/fronted/dialer.go b/src/github.com/getlantern/fronted/dialer.go index 4b4dcd7755..fb464cf0fc 100644 --- a/src/github.com/getlantern/fronted/dialer.go +++ b/src/github.com/getlantern/fronted/dialer.go @@ -237,12 +237,12 @@ func (d *dialer) NewDirectDomainFronter() *http.Client { func (d *dialer) enproxyConfigWith(dialProxy func(addr string) (net.Conn, error)) *enproxy.Config { return &enproxy.Config{ DialProxy: dialProxy, - NewRequest: func(upstreamHost string, method string, body io.Reader) (req *http.Request, err error) { + NewRequest: func(upstreamHost, path, method string, body io.Reader) (req *http.Request, err error) { if upstreamHost == "" { // No specific host requested, use configured one upstreamHost = d.Host } - return http.NewRequest(method, "http://"+upstreamHost+"/", body) + return http.NewRequest(method, "http://"+upstreamHost+"/"+path+"/", body) }, BufferRequests: d.BufferRequests, IdleTimeout: idleTimeout, // TODO: make this configurable