X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/95ec747218f048e5bbfb986ff4eaeba2d3d2f80b..987457b7e545f4ad1e32c7a07c00c29c24326421:/services/keep-web/handler.go diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go index c9148a562e..19a2040b4a 100644 --- a/services/keep-web/handler.go +++ b/services/keep-web/handler.go @@ -91,8 +91,10 @@ func (h *handler) setup() { func (h *handler) serveStatus(w http.ResponseWriter, r *http.Request) { status := struct { cacheStats + Version string }{ cacheStats: h.Config.Cache.Stats(), + Version: version, } json.NewEncoder(w).Encode(status) } @@ -139,6 +141,7 @@ func (uos *updateOnSuccess) WriteHeader(code int) { var ( writeMethod = map[string]bool{ + "COPY": true, "DELETE": true, "MKCOL": true, "MOVE": true, @@ -146,6 +149,7 @@ var ( "RMCOL": true, } webdavMethod = map[string]bool{ + "COPY": true, "DELETE": true, "MKCOL": true, "MOVE": true, @@ -200,7 +204,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { return } w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Range") - w.Header().Set("Access-Control-Allow-Methods", "DELETE, GET, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PUT, RMCOL") + w.Header().Set("Access-Control-Allow-Methods", "COPY, DELETE, GET, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PUT, RMCOL") w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Max-Age", "86400") statusCode = http.StatusOK @@ -415,9 +419,15 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { statusCode, statusText = http.StatusInternalServerError, err.Error() return } + + targetIsPDH := arvadosclient.PDHMatch(targetID) + if targetIsPDH && writeMethod[r.Method] { + statusCode, statusText = http.StatusMethodNotAllowed, errReadOnly.Error() + return + } + if webdavMethod[r.Method] { - writing := !arvadosclient.PDHMatch(targetID) && writeMethod[r.Method] - if writing { + if writeMethod[r.Method] { // Save the collection only if/when all // webdav->filesystem operations succeed -- // and send a 500 error if the modified @@ -431,8 +441,9 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { h := webdav.Handler{ Prefix: "/" + strings.Join(pathParts[:stripParts], "/"), FileSystem: &webdavFS{ - collfs: fs, - writing: writing, + collfs: fs, + writing: writeMethod[r.Method], + alwaysReadEOF: r.Method == "PROPFIND", }, LockSystem: h.webdavLS, Logger: func(_ *http.Request, err error) {