9799: Merge branch 'master' into 9799-nonadmin-logs
[arvados.git] / services / keep-web / handler.go
index c947a6efcd1189137afbe4debd5b4bc2c78c0921..6f5f66ae0ef1bf57979f04189fe4d110818b1bd6 100644 (file)
@@ -101,8 +101,11 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
        }
 
        if r.Header.Get("Origin") != "" {
-               // Allow simple cross-origin requests, without
-               // credentials.
+               // Allow simple cross-origin requests without user
+               // credentials ("user credentials" as defined by CORS,
+               // i.e., cookies, HTTP authentication, and client-side
+               // SSL certificates. See
+               // http://www.w3.org/TR/cors/#user-credentials).
                w.Header().Set("Access-Control-Allow-Origin", "*")
        }
 
@@ -317,6 +320,12 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
                statusCode, statusText = http.StatusInternalServerError, err.Error()
                return
        }
+       if kc.Client != nil && kc.Client.Transport != nil {
+               // Workaround for https://dev.arvados.org/issues/9005
+               if t, ok := kc.Client.Transport.(*http.Transport); ok {
+                       defer t.CloseIdleConnections()
+               }
+       }
        rdr, err := kc.CollectionFileReader(collection, filename)
        if os.IsNotExist(err) {
                statusCode = http.StatusNotFound