提交 d20926f4 作者: Juan Batiz-Benet

Merge pull request #932 from andyleap/gateway404

Fixes issue #924
...@@ -174,15 +174,7 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { ...@@ -174,15 +174,7 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) {
nd, p, err := i.ResolvePath(ctx, urlPath) nd, p, err := i.ResolvePath(ctx, urlPath)
if err != nil { if err != nil {
if err == routing.ErrNotFound { webError(w, "Path Resolve error", err, http.StatusBadRequest)
w.WriteHeader(http.StatusNotFound)
} else if err == context.DeadlineExceeded {
w.WriteHeader(http.StatusRequestTimeout)
} else {
w.WriteHeader(http.StatusBadRequest)
}
w.Write([]byte(err.Error()))
return return
} }
......
...@@ -91,7 +91,7 @@ func TestGatewayGet(t *testing.T) { ...@@ -91,7 +91,7 @@ func TestGatewayGet(t *testing.T) {
{"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"},
{"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"},
{"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"},
{"localhost:5001", "/ipns/nxdomain.example.com", http.StatusBadRequest, namesys.ErrResolveFailed.Error()}, {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusBadRequest, "Path Resolve error: " + namesys.ErrResolveFailed.Error()},
{"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"},
{"example.com", "/", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"},
} { } {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论