Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
fileserver: Add a few more debug lines (#4063)
Francis Lavoie committed
Mar 19, 2021 at 13:42 UTC
0018b9be0d2e409cd80367c9e8403188723d0996
1 file changed
+3
modules/caddyhttp/fileserver/staticfiles.go
+3
@@ -295,8 +295,10 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (*os.Fi
295
if err != nil {
296
err = mapDirOpenError(err, filename)
297
if os.IsNotExist(err) {
298
+ fsrv.logger.Debug("file not found", zap.String("filename", filename), zap.Error(err))
299
return nil, caddyhttp.Error(http.StatusNotFound, err)
300
} else if os.IsPermission(err) {
301
+ fsrv.logger.Debug("permission denied", zap.String("filename", filename), zap.Error(err))
302
return nil, caddyhttp.Error(http.StatusForbidden, err)
303
}
304
// maybe the server is under load and ran out of file descriptors?
@@ -304,6 +306,7 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (*os.Fi
306
//nolint:gosec
307
backoff := weakrand.Intn(maxBackoff-minBackoff) + minBackoff
308
w.Header().Set("Retry-After", strconv.Itoa(backoff))
309
+ fsrv.logger.Debug("retry after backoff", zap.String("filename", filename), zap.Int("backoff", backoff), zap.Error(err))
310
return nil, caddyhttp.Error(http.StatusServiceUnavailable, err)
311
}
312
return file, nil