Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #74 from jehiah/request_path_74
Browse files Browse the repository at this point in the history
request path contains full URL
  • Loading branch information
jehiah committed Mar 22, 2015
2 parents 736ec2a + 16f2c98 commit e1f4941
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions oauthproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func setProxyUpstreamHostHeader(proxy *httputil.ReverseProxy, target *url.URL) {
proxy.Director = func(req *http.Request) {
director(req)
// use RequestURI so that we aren't unescaping encoded slashes in the request path
req.URL.Opaque = fmt.Sprintf("//%s%s", target.Host, req.RequestURI)
req.Host = target.Host
req.URL.Opaque = req.RequestURI
req.URL.RawQuery = ""
}
}
Expand All @@ -76,7 +77,7 @@ func setProxyDirector(proxy *httputil.ReverseProxy) {
proxy.Director = func(req *http.Request) {
director(req)
// use RequestURI so that we aren't unescaping encoded slashes in the request path
req.URL.Opaque = fmt.Sprintf("//%s%s", req.URL.Host, req.RequestURI)
req.URL.Opaque = req.RequestURI
req.URL.RawQuery = ""
}
}
Expand Down
7 changes: 3 additions & 4 deletions oauthproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ func TestEncodedSlashes(t *testing.T) {
defer frontend.Close()

f, _ := url.Parse(frontend.URL)
encodedPath := "/a%2Fb/"
encodedPath := "/a%2Fb/?c=1"
getReq := &http.Request{URL: &url.URL{Scheme: "http", Host: f.Host, Opaque: encodedPath}}
_, err := http.DefaultClient.Do(getReq)
if err != nil {
t.Fatalf("err %s", err)
}
expected := backend.URL + encodedPath
if seen != expected {
t.Errorf("got bad request %q expected %q", seen, expected)
if seen != encodedPath {
t.Errorf("got bad request %q expected %q", seen, encodedPath)
}
}

0 comments on commit e1f4941

Please sign in to comment.