From a1312465b5b1b487cc11a1c9445d346dfa52a589 Mon Sep 17 00:00:00 2001 From: Abiola Ibrahim Date: Sun, 10 May 2015 17:56:03 +0100 Subject: [PATCH] browse: return forbidden (403) only when it is a permission error. --- middleware/browse/browse.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/middleware/browse/browse.go b/middleware/browse/browse.go index d09bd253..9826bf69 100644 --- a/middleware/browse/browse.go +++ b/middleware/browse/browse.go @@ -99,7 +99,10 @@ func (b Browse) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { // Load directory contents file, err := os.Open(b.Root + r.URL.Path) if err != nil { - return http.StatusForbidden, err + if os.IsPermission(err) { + return http.StatusForbidden, err + } + return http.StatusNotFound, err } defer file.Close()