[ARVADOS] created: 1.3.0-2168-g46d2ed572

Git user git at public.arvados.org
Fri Feb 14 18:41:40 UTC 2020


        at  46d2ed57248419200d5716cfef8de9a1bb911240 (commit)


commit 46d2ed57248419200d5716cfef8de9a1bb911240
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Fri Feb 14 13:40:01 2020 -0500

    16100: Add package dependency for /etc/mime.types.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/services/keep-web/fpm-info.sh b/services/keep-web/fpm-info.sh
new file mode 100644
index 000000000..6bcbf67fe
--- /dev/null
+++ b/services/keep-web/fpm-info.sh
@@ -0,0 +1,12 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+case "$TARGET" in
+    centos*)
+        fpm_depends+=(mailcap)
+        ;;
+    debian* | ubuntu*)
+        fpm_depends+=(mime-support)
+        ;;
+esac

commit 2126b36e873d5412f9c38e3d109748af8df29612
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Fri Feb 14 13:39:38 2020 -0500

    16100: Log a warning if /etc/mime.types is missing.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/services/keep-web/main.go b/services/keep-web/main.go
index f028cca22..e4028842f 100644
--- a/services/keep-web/main.go
+++ b/services/keep-web/main.go
@@ -7,6 +7,7 @@ package main
 import (
 	"flag"
 	"fmt"
+	"mime"
 	"os"
 
 	"git.arvados.org/arvados.git/lib/config"
@@ -104,6 +105,10 @@ func main() {
 
 	log.Printf("keep-web %s started", version)
 
+	if ext := ".txt"; mime.TypeByExtension(ext) == "" {
+		log.Warnf("cannot look up MIME type for %q -- this probably means /etc/mime.types is missing -- clients will see incorrect content types", ext)
+	}
+
 	os.Setenv("ARVADOS_API_HOST", cfg.cluster.Services.Controller.ExternalURL.Host)
 	srv := &server{Config: cfg}
 	if err := srv.Start(); err != nil {

commit 72e59ac7d694d654fc669b94d4f33151d77bc694
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Fri Feb 14 13:25:30 2020 -0500

    16100: Test content-type detection.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/services/keep-web/handler_test.go b/services/keep-web/handler_test.go
index 29bcdac1b..488c91cdc 100644
--- a/services/keep-web/handler_test.go
+++ b/services/keep-web/handler_test.go
@@ -19,6 +19,7 @@ import (
 
 	"git.arvados.org/arvados.git/lib/config"
 	"git.arvados.org/arvados.git/sdk/go/arvados"
+	"git.arvados.org/arvados.git/sdk/go/arvadosclient"
 	"git.arvados.org/arvados.git/sdk/go/arvadostest"
 	"git.arvados.org/arvados.git/sdk/go/auth"
 	"git.arvados.org/arvados.git/sdk/go/ctxlog"
@@ -933,6 +934,66 @@ func (s *IntegrationSuite) TestHealthCheckPing(c *check.C) {
 	c.Check(resp.Body.String(), check.Matches, `{"health":"OK"}\n`)
 }
 
+func (s *IntegrationSuite) TestFileContentType(c *check.C) {
+	s.testServer.Config.cluster.Services.WebDAVDownload.ExternalURL.Host = "download.example.com"
+
+	client := s.testServer.Config.Client
+	client.AuthToken = arvadostest.ActiveToken
+	arv, err := arvadosclient.New(&client)
+	c.Assert(err, check.Equals, nil)
+	kc, err := keepclient.MakeKeepClient(arv)
+	c.Assert(err, check.Equals, nil)
+
+	fs, err := (&arvados.Collection{}).FileSystem(&client, kc)
+	c.Assert(err, check.IsNil)
+
+	trials := []struct {
+		filename    string
+		content     string
+		contentType string
+	}{
+		{"picture.txt", "BMX bikes are small this year\n", "text/plain; charset=utf-8"},
+		{"picture.bmp", "BMX bikes are small this year\n", "image/x-ms-bmp"},
+		{"picture.jpg", "BMX bikes are small this year\n", "image/jpeg"},
+		{"picture1", "BMX bikes are small this year\n", "image/bmp"},            // content sniff; "BM" is the magic signature for .bmp
+		{"picture2", "Cars are small this year\n", "text/plain; charset=utf-8"}, // content sniff
+	}
+	for _, trial := range trials {
+		f, err := fs.OpenFile(trial.filename, os.O_CREATE|os.O_WRONLY, 0777)
+		c.Assert(err, check.IsNil)
+		_, err = f.Write([]byte(trial.content))
+		c.Assert(err, check.IsNil)
+		c.Assert(f.Close(), check.IsNil)
+	}
+	mtxt, err := fs.MarshalManifest(".")
+	c.Assert(err, check.IsNil)
+	var coll arvados.Collection
+	err = client.RequestAndDecode(&coll, "POST", "arvados/v1/collections", nil, map[string]interface{}{
+		"collection": map[string]string{
+			"manifest_text": mtxt,
+		},
+	})
+	c.Assert(err, check.IsNil)
+
+	for _, trial := range trials {
+		u, _ := url.Parse("http://download.example.com/by_id/" + coll.UUID + "/" + trial.filename)
+		req := &http.Request{
+			Method:     "GET",
+			Host:       u.Host,
+			URL:        u,
+			RequestURI: u.RequestURI(),
+			Header: http.Header{
+				"Authorization": {"Bearer " + client.AuthToken},
+			},
+		}
+		resp := httptest.NewRecorder()
+		s.testServer.Handler.ServeHTTP(resp, req)
+		c.Check(resp.Code, check.Equals, http.StatusOK)
+		c.Check(resp.Header().Get("Content-Type"), check.Equals, trial.contentType)
+		c.Check(resp.Body.String(), check.Equals, trial.content)
+	}
+}
+
 func copyHeader(h http.Header) http.Header {
 	hc := http.Header{}
 	for k, v := range h {

commit 530db6b1a9e164213422da56a38f2551a559747d
Author: Tom Clegg <tom at tomclegg.ca>
Date:   Thu Feb 13 02:29:22 2020 -0500

    16100: Fix bogus timing stats for empty responses.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at tomclegg.ca>

diff --git a/sdk/go/httpserver/logger.go b/sdk/go/httpserver/logger.go
index 30f5e2612..8886f9517 100644
--- a/sdk/go/httpserver/logger.go
+++ b/sdk/go/httpserver/logger.go
@@ -68,10 +68,16 @@ func logRequest(w *responseTimer, req *http.Request, lgr *logrus.Entry) {
 func logResponse(w *responseTimer, req *http.Request, lgr *logrus.Entry) {
 	if tStart, ok := req.Context().Value(&requestTimeContextKey).(time.Time); ok {
 		tDone := time.Now()
+		writeTime := w.writeTime
+		if !w.wrote {
+			// Empty response body. Header was sent when
+			// handler exited.
+			writeTime = tDone
+		}
 		lgr = lgr.WithFields(logrus.Fields{
 			"timeTotal":     stats.Duration(tDone.Sub(tStart)),
-			"timeToStatus":  stats.Duration(w.writeTime.Sub(tStart)),
-			"timeWriteBody": stats.Duration(tDone.Sub(w.writeTime)),
+			"timeToStatus":  stats.Duration(writeTime.Sub(tStart)),
+			"timeWriteBody": stats.Duration(tDone.Sub(writeTime)),
 		})
 	}
 	respCode := w.WroteStatus()

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list