This commit is contained in:
Matthew Holt 2017-04-21 13:02:15 -06:00
parent 182e1b4fb2
commit f8614b877d
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
2 changed files with 1 additions and 9 deletions

View file

@ -26,7 +26,6 @@ import (
"github.com/mholt/caddy/caddyfile" "github.com/mholt/caddy/caddyfile"
"github.com/mholt/caddy/caddyhttp/httpserver" "github.com/mholt/caddy/caddyhttp/httpserver"
"github.com/mholt/caddy/caddyhttp/staticfiles"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
) )
@ -995,8 +994,6 @@ func TestProxyDirectorURL(t *testing.T) {
t.Errorf("case %d failed to create request: %s", i, err) t.Errorf("case %d failed to create request: %s", i, err)
continue continue
} }
req = req.WithContext(context.WithValue(req.Context(),
staticfiles.URLPathCtxKey, c.originalPath))
NewSingleHostReverseProxy(targetURL, c.without, 0).Director(req) NewSingleHostReverseProxy(targetURL, c.without, 0).Director(req)
if expect, got := c.expectURL, req.URL.String(); expect != got { if expect, got := c.expectURL, req.URL.String(); expect != got {

View file

@ -159,12 +159,7 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) *
prefer(target.RawPath, target.Path), prefer(target.RawPath, target.Path),
prefer(req.URL.RawPath, req.URL.Path)) prefer(req.URL.RawPath, req.URL.Path))
} }
req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path)
prefer(untouchedPath, req.URL.Path))
// req.URL.Path must be consistent with decoded form of req.URL.RawPath if any
if req.URL.RawPath != "" && req.URL.RawPath != req.URL.EscapedPath() {
panic("RawPath doesn't match Path")
}
// Trims the path of the socket from the URL path. // Trims the path of the socket from the URL path.
// This is done because req.URL passed to your proxied service // This is done because req.URL passed to your proxied service