summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2015-04-30 11:58:38 -0600
committerMatthew Holt <[email protected]>2015-04-30 11:58:38 -0600
commit37e3fe5f1f82d5199baf383b66645fa9be4dcc8f (patch)
treeacaa1248aa911f1f77c99cb1b3642becb9c6a860
parent9dfbbbcda4b388f8070cab1bdc1585e8a54a5794 (diff)
downloadcaddy-37e3fe5f1f82d5199baf383b66645fa9be4dcc8f.tar.gz
caddy-37e3fe5f1f82d5199baf383b66645fa9be4dcc8f.zip
core: Fix dyslexic/backward handling of 403/404 errorsv0.5.1
-rw-r--r--server/fileserver.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/server/fileserver.go b/server/fileserver.go
index 184b694b0..dc5af4b53 100644
--- a/server/fileserver.go
+++ b/server/fileserver.go
@@ -42,9 +42,9 @@ func (fh *fileHandler) serveFile(w http.ResponseWriter, r *http.Request, name st
f, err := fh.root.Open(name)
if err != nil {
if os.IsNotExist(err) {
- return http.StatusForbidden, err
- } else if os.IsPermission(err) {
return http.StatusNotFound, nil
+ } else if os.IsPermission(err) {
+ return http.StatusForbidden, err
}
// Likely the server is under load and ran out of file descriptors
w.Header().Set("Retry-After", "5") // TODO: 5 seconds enough delay? Or too much?
@@ -54,10 +54,10 @@ func (fh *fileHandler) serveFile(w http.ResponseWriter, r *http.Request, name st
d, err1 := f.Stat()
if err1 != nil {
- if os.IsPermission(err) {
- return http.StatusForbidden, err
- } else if os.IsNotExist(err) {
+ if os.IsNotExist(err) {
return http.StatusNotFound, nil
+ } else if os.IsPermission(err) {
+ return http.StatusForbidden, err
}
// Return a different status code than above so as to distinguish these cases
return http.StatusInternalServerError, err