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

Commit e1f4941

Browse files
committed
Merge pull request #74 from jehiah/request_path_74
request path contains full URL
2 parents 736ec2a + 16f2c98 commit e1f4941

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

oauthproxy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ func setProxyUpstreamHostHeader(proxy *httputil.ReverseProxy, target *url.URL) {
6767
proxy.Director = func(req *http.Request) {
6868
director(req)
6969
// use RequestURI so that we aren't unescaping encoded slashes in the request path
70-
req.URL.Opaque = fmt.Sprintf("//%s%s", target.Host, req.RequestURI)
70+
req.Host = target.Host
71+
req.URL.Opaque = req.RequestURI
7172
req.URL.RawQuery = ""
7273
}
7374
}
@@ -76,7 +77,7 @@ func setProxyDirector(proxy *httputil.ReverseProxy) {
7677
proxy.Director = func(req *http.Request) {
7778
director(req)
7879
// use RequestURI so that we aren't unescaping encoded slashes in the request path
79-
req.URL.Opaque = fmt.Sprintf("//%s%s", req.URL.Host, req.RequestURI)
80+
req.URL.Opaque = req.RequestURI
8081
req.URL.RawQuery = ""
8182
}
8283
}

oauthproxy_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ func TestEncodedSlashes(t *testing.T) {
5151
defer frontend.Close()
5252

5353
f, _ := url.Parse(frontend.URL)
54-
encodedPath := "/a%2Fb/"
54+
encodedPath := "/a%2Fb/?c=1"
5555
getReq := &http.Request{URL: &url.URL{Scheme: "http", Host: f.Host, Opaque: encodedPath}}
5656
_, err := http.DefaultClient.Do(getReq)
5757
if err != nil {
5858
t.Fatalf("err %s", err)
5959
}
60-
expected := backend.URL + encodedPath
61-
if seen != expected {
62-
t.Errorf("got bad request %q expected %q", seen, expected)
60+
if seen != encodedPath {
61+
t.Errorf("got bad request %q expected %q", seen, encodedPath)
6362
}
6463
}

0 commit comments

Comments
 (0)