Skip to content

Commit

Permalink
add path parameter to newRequestFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
fffw committed Sep 1, 2015
1 parent aa6ad95 commit 4c547c2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/github.com/getlantern/enproxy/conn_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/github.com/getlantern/enproxy/conn_intf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/github.com/getlantern/enproxy/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/github.com/getlantern/fronted/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c547c2

Please sign in to comment.