-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http/httputil: ReverseProxy doesn't handle empty path #25710
Comments
Actually, url path is not "". url path is "/". So it's joining: "/b" + "/" == "/b/". But I agree that this is an unexpected result. Though if we fixed this, it might break existing code. Here's a more complete, minimal reproduction:
request: |
@meirf if you use |
/cc @bradfitz |
The empty url Path "" generated by StripPrefix is OK. If "/" is generated instead, the request to /b will become /b/ when it reach the backend server. |
@joekyo yes, this is what I thought, or we can do this check before |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.1 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hao/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hao/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wc/gl6jp38s3lqdprky1txx23mr0000gn/T/go-build181870961=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
What did you expect to see?
proxy to
http://localhost:8000/b
What did you see instead?
proxy to
http://localhost:8000/b/
, adding an extra slash.this line add a slash even if url path is empty. is this expected behavior or a bug?
The text was updated successfully, but these errors were encountered: