Open jxskiss opened 4 years ago
It redirects between "/users/profile/" and "/users/profile" cyclically, which is not expected. Since neither "/users/profile/" and "/users/profile" is registered, I think it should not redirect "/users/profile/" to "/users/profile", but should go to NotFound instead.
@julienschmidt Hi, sorry to bother, would you please look into this?
Here's a reduced test case:
package main
import (
"github.com/julienschmidt/httprouter"
"net/http"
)
func main() {
r := &httprouter.Router{}
r.RedirectTrailingSlash = true
r.GET("/a/:id/b/", dummyHandler)
http.ListenAndServe("localhost:9000", r)
}
func dummyHandler(_ http.ResponseWriter, _ *http.Request, _ httprouter.Params) {}
So long as RedirectTrailingSlash
is enabled, a request to GET /a/x/
will be redirected to /a/x
, despite there being no handler registered for that path. (This is specific to requests under /a/
; requests under other paths will not be redirected similarly.)
I was running a python service and a go service before it, the go service handles some endpoints and proxy requests which not found to the python service. And I ran into a situation which redirect to death.
The following code will reproduce the bug when accessing "http://127.0.0.1:8080/users/profile/".