X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6522329120f0e2a73bf9c55f4f937fa3d109803d..fd86245d5c68c0c82224030e98b7f26974dc1b5c:/services/keep-web/handler.go diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go index 06185882dc..4ffac26797 100644 --- a/services/keep-web/handler.go +++ b/services/keep-web/handler.go @@ -14,6 +14,7 @@ import ( "net/http" "net/url" "os" + "path/filepath" "sort" "strconv" "strings" @@ -335,7 +336,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { } if useSiteFS { - h.serveSiteFS(w, r, tokens, credentialsOK) + h.serveSiteFS(w, r, tokens, credentialsOK, attachment) return } @@ -423,11 +424,11 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { } applyContentDispositionHdr(w, r, basename, attachment) - client := &arvados.Client{ + client := (&arvados.Client{ APIHost: arv.ApiServer, AuthToken: arv.ApiToken, Insecure: arv.ApiInsecure, - } + }).WithRequestID(r.Header.Get("X-Request-Id")) fs, err := collection.FileSystem(client, kc) if err != nil { @@ -505,7 +506,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { } } -func (h *handler) serveSiteFS(w http.ResponseWriter, r *http.Request, tokens []string, credentialsOK bool) { +func (h *handler) serveSiteFS(w http.ResponseWriter, r *http.Request, tokens []string, credentialsOK, attachment bool) { if len(tokens) == 0 { w.Header().Add("WWW-Authenticate", "Basic realm=\"collections\"") http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) @@ -528,11 +529,11 @@ func (h *handler) serveSiteFS(w http.ResponseWriter, r *http.Request, tokens []s http.Error(w, err.Error(), http.StatusInternalServerError) return } - client := &arvados.Client{ + client := (&arvados.Client{ APIHost: arv.ApiServer, AuthToken: arv.ApiToken, Insecure: arv.ApiInsecure, - } + }).WithRequestID(r.Header.Get("X-Request-Id")) fs := client.SiteFileSystem(kc) f, err := fs.Open(r.URL.Path) if os.IsNotExist(err) { @@ -551,6 +552,10 @@ func (h *handler) serveSiteFS(w http.ResponseWriter, r *http.Request, tokens []s } return } + if r.Method == "GET" { + _, basename := filepath.Split(r.URL.Path) + applyContentDispositionHdr(w, r, basename, attachment) + } wh := webdav.Handler{ Prefix: "/", FileSystem: &webdavFS{