|
|
@ -24,14 +24,7 @@ func (h *Handler) handlePROPFIND(w http.ResponseWriter, r *http.Request) {
|
|
|
|
// Delegate to a Child.
|
|
|
|
// Delegate to a Child.
|
|
|
|
depth := getDepth(r)
|
|
|
|
depth := getDepth(r)
|
|
|
|
|
|
|
|
|
|
|
|
cached := h.StatCache.get(r.URL.Path, depth)
|
|
|
|
status, result := h.StatCache.getOr(r.URL.Path, depth, func() (int, []byte) {
|
|
|
|
if cached != nil {
|
|
|
|
|
|
|
|
w.Header().Del("Content-Length")
|
|
|
|
|
|
|
|
w.WriteHeader(http.StatusMultiStatus)
|
|
|
|
|
|
|
|
w.Write(cached)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Use a buffering ResponseWriter so that we can manipulate the result.
|
|
|
|
// Use a buffering ResponseWriter so that we can manipulate the result.
|
|
|
|
// The only thing we use from the original ResponseWriter is Header().
|
|
|
|
// The only thing we use from the original ResponseWriter is Header().
|
|
|
|
bw := &bufferingResponseWriter{ResponseWriter: w}
|
|
|
|
bw := &bufferingResponseWriter{ResponseWriter: w}
|
|
|
@ -43,14 +36,14 @@ func (h *Handler) handlePROPFIND(w http.ResponseWriter, r *http.Request) {
|
|
|
|
pathPrefix := shared.Join(pathComponents[0:mpl]...)
|
|
|
|
pathPrefix := shared.Join(pathComponents[0:mpl]...)
|
|
|
|
b := hrefRegex.ReplaceAll(bw.buf.Bytes(), []byte(fmt.Sprintf("<D:href>%s/$1</D:href>", pathPrefix)))
|
|
|
|
b := hrefRegex.ReplaceAll(bw.buf.Bytes(), []byte(fmt.Sprintf("<D:href>%s/$1</D:href>", pathPrefix)))
|
|
|
|
|
|
|
|
|
|
|
|
if h.StatCache != nil && bw.status == http.StatusMultiStatus && b != nil {
|
|
|
|
return bw.status, b
|
|
|
|
h.StatCache.set(r.URL.Path, depth, b)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w.Header().Del("Content-Length")
|
|
|
|
w.Header().Del("Content-Length")
|
|
|
|
w.WriteHeader(bw.status)
|
|
|
|
w.WriteHeader(status)
|
|
|
|
w.Write(b)
|
|
|
|
if result != nil {
|
|
|
|
|
|
|
|
w.Write(result)
|
|
|
|
|
|
|
|
}
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|