From 557e5cbde43a7ff5187f9b737cb341becdcc8ef4 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 4 Oct 2016 18:25:23 +0200 Subject: [PATCH] gateway: change status code of failed namesys resution to 500 License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@ce96b915e75392baaa866b6f23e58f42f862f9d6 --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 0e45c198c..9a665d95c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -168,7 +168,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr dir = true case namesys.ErrResolveFailed: // Don't log that error as it is just noise - w.WriteHeader(http.StatusBadRequest) + w.WriteHeader(http.StatusInternalServerError) fmt.Fprintf(w, "Path Resolve error: %s", err.Error()) log.Info("Path Resolve error: %s", err.Error()) return diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 42e0a6ac9..d4b0e9075 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -136,7 +136,7 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/", 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", "/ipns/nxdomain.example.com", http.StatusBadRequest, "Path Resolve error: " + namesys.ErrResolveFailed.Error()}, + {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusInternalServerError, "Path Resolve error: " + namesys.ErrResolveFailed.Error()}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, } {