git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #74 from jehiah/request_path_74

request path contains full URL

commite1f49415223bf39c6483dff6502b07a332b6b287 authorJehiah Czebotar <jehiah@gmail.com> dateSun 22 Mar 2015, 07:56 (12 years ago) parent736ec2a16f2c98
2 files changed+6−6
oauthproxy.go+3−2 oauthproxy_test.go+3−4
oauthproxy.go+3−2
@@ -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+3−4
@@ -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}