mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-23 19:46:56 +08:00
core: Fix dyslexic/backward handling of 403/404 errors
This commit is contained in:
parent
9dfbbbcda4
commit
37e3fe5f1f
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user