projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
12167: Propagate X-Request-Id in API calls.
[arvados.git]
/
services
/
keep-web
/
handler.go
diff --git
a/services/keep-web/handler.go
b/services/keep-web/handler.go
index 06185882dcd781bc133e0c42a0756dc31e21342e..4ffac26797514de7317099307f36e3be57b3da89 100644
(file)
--- a/
services/keep-web/handler.go
+++ b/
services/keep-web/handler.go
@@
-14,6
+14,7
@@
import (
"net/http"
"net/url"
"os"
"net/http"
"net/url"
"os"
+ "path/filepath"
"sort"
"strconv"
"strings"
"sort"
"strconv"
"strings"
@@
-335,7
+336,7
@@
func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
}
if useSiteFS {
}
if useSiteFS {
- h.serveSiteFS(w, r, tokens, credentialsOK)
+ h.serveSiteFS(w, r, tokens, credentialsOK
, attachment
)
return
}
return
}
@@
-423,11
+424,11
@@
func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
}
applyContentDispositionHdr(w, r, basename, attachment)
}
applyContentDispositionHdr(w, r, basename, attachment)
- client := &arvados.Client{
+ client :=
(
&arvados.Client{
APIHost: arv.ApiServer,
AuthToken: arv.ApiToken,
Insecure: arv.ApiInsecure,
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 {
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)
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
}
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- client := &arvados.Client{
+ client :=
(
&arvados.Client{
APIHost: arv.ApiServer,
AuthToken: arv.ApiToken,
Insecure: arv.ApiInsecure,
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) {
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
}
}
return
}
+ if r.Method == "GET" {
+ _, basename := filepath.Split(r.URL.Path)
+ applyContentDispositionHdr(w, r, basename, attachment)
+ }
wh := webdav.Handler{
Prefix: "/",
FileSystem: &webdavFS{
wh := webdav.Handler{
Prefix: "/",
FileSystem: &webdavFS{