added offline mode
This commit is contained in:
parent
b13ff70a2d
commit
d2b91f2db4
4 changed files with 105 additions and 38 deletions
|
|
@ -49,7 +49,7 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
r.URL.Path = upath
|
||||
}
|
||||
p := path.Clean(upath)
|
||||
d, err := fs.fs.Stat(p)
|
||||
d, offline, err := fs.fs.StatWithOffline(p)
|
||||
if err != nil {
|
||||
msg, code := toHTTPError(err)
|
||||
http.Error(w, msg, code)
|
||||
|
|
@ -82,7 +82,16 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
i := &responseInterceptor{w: w}
|
||||
// TODO implement directory listing cache
|
||||
offline = true
|
||||
if offline {
|
||||
r.Header.Del("If-Modified-Since")
|
||||
r.Header.Del("Cache-Control")
|
||||
}
|
||||
fs.h.ServeHTTP(i, r)
|
||||
if offline {
|
||||
w.Header().Del("Last-Modified")
|
||||
}
|
||||
paths, err := i.GetPaths()
|
||||
if err == io.EOF {
|
||||
w.WriteHeader(i.Status())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue