301 is reported as 404 for http post

fix https://github.com/chrislusf/seaweedfs/issues/512
This commit is contained in:
Chris Lu
2017-06-15 21:21:32 -07:00
parent 761c0eb1ed
commit 72e89b615b
2 changed files with 11 additions and 11 deletions

View File

@@ -44,8 +44,10 @@ func (s *RaftServer) HandleFunc(pattern string, handler func(http.ResponseWriter
func (s *RaftServer) redirectToLeader(w http.ResponseWriter, req *http.Request) {
if leader, e := s.topo.Leader(); e == nil {
//http.StatusMovedPermanently does not cause http POST following redirection
glog.V(0).Infoln("Redirecting to", http.StatusMovedPermanently, "http://"+leader+req.URL.Path)
http.Redirect(w, req, "http://"+leader+req.URL.Path, http.StatusMovedPermanently)
learderLocation := "http://" + leader + req.URL.Path
glog.V(0).Infoln("Redirecting to", learderLocation)
writeJsonQuiet(w, req, http.StatusOK, learderLocation)
// http.Redirect(w, req, "http://"+leader+req.URL.Path, http.StatusFound) // not working any more
} else {
glog.V(0).Infoln("Error: Leader Unknown")
http.Error(w, "Leader unknown", http.StatusInternalServerError)