// Highly-customizable HTTP, HTTP/2, HTTPS server
package godlighty
-const Version = "godlighty/0.2.0"
+const Version = "godlighty/0.3.0"
var BindAddr string
)
http.NotFound(w, r)
}
+ w.Header().Set("Server", Version)
if cfg == nil {
notFound()
return
return
}
- if cfg.WebDAV && (r.Method == http.MethodHead ||
+ pthOrig := path.Clean(path.Join(cfg.Root, r.URL.Path))
+ pth := pthOrig
+ fi, err := os.Stat(pth)
+ if err != nil {
+ notFound()
+ return
+ }
+
+ if cfg.WebDAV && (((r.Method == http.MethodHead) && fi.IsDir()) ||
r.Method == http.MethodOptions ||
r.Method == "PROPFIND") {
dav := webdav.Handler{
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
+
var fd *os.File
var contentType string
var etag string
- pthOrig := path.Clean(path.Join(cfg.Root, r.URL.Path))
- pth := pthOrig
-IndexLookup:
- fi, err := os.Stat(pth)
- if err != nil {
- notFound()
- return
- }
+IndexLookuped:
if fi.IsDir() {
if cfg.DirList {
entries, err := os.ReadDir(pth)
p := path.Join(pth, index)
if _, err := os.Stat(p); err == nil {
pth = p
- goto IndexLookup
+ fi, err = os.Stat(pth)
+ if err != nil {
+ notFound()
+ return
+ }
+ goto IndexLookuped
}
}
notFound()
contentTypeBase := strings.SplitN(contentType, ";", 2)[0]
w.Header().Set("Content-Type", contentType)
- w.Header().Set("Server", Version)
if etag != "" {
w.Header().Set("ETag", etag)
}