aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-09-30 13:44:27 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-09-30 16:03:15 +0200
commitfeb5635181eb12a6e3516172a3f5af06a3bc93e1 (patch)
treede2a1f5e796c8d25d3950d02b346f323d8d1448c /pkg
parent5e8ac358946b8898e30bb3d9642a1ce5e5b15a5a (diff)
pkg/asset: don't set encoding by default
It causes web browsers to decompress archives in place, which makes it more confusing for the users since the file extension remains in place. The only exception is html coverage reports, adjust the code to handle that.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/asset/storage.go6
-rw-r--r--pkg/asset/type.go2
2 files changed, 3 insertions, 5 deletions
diff --git a/pkg/asset/storage.go b/pkg/asset/storage.go
index e790732bd..0b008b744 100644
--- a/pkg/asset/storage.go
+++ b/pkg/asset/storage.go
@@ -112,6 +112,7 @@ func (storage *Storage) uploadFileStream(reader io.Reader, assetType dashapi.Ass
req := &uploadRequest{
savePath: path,
contentType: typeDescr.ContentType,
+ contentEncoding: typeDescr.ContentEncoding,
preserveExtension: typeDescr.preserveExtension,
}
if req.contentType == "" {
@@ -287,10 +288,6 @@ func xzCompressor(req *uploadRequest,
if !req.preserveExtension {
newReq.savePath = fmt.Sprintf("%s.xz", newReq.savePath)
}
- // "gz" contentEncoding is not really supported so far, so let's just set contentType.
- if newReq.contentType == "" {
- newReq.contentType = "application/x-xz"
- }
resp, err := next(&newReq)
if err != nil {
return nil, err
@@ -342,7 +339,6 @@ func gzipCompressor(req *uploadRequest,
if !req.preserveExtension {
newReq.savePath = fmt.Sprintf("%s.gz", newReq.savePath)
}
- newReq.contentEncoding = "gzip"
resp, err := next(&newReq)
if err != nil {
return nil, err
diff --git a/pkg/asset/type.go b/pkg/asset/type.go
index 1fd218da8..e88198266 100644
--- a/pkg/asset/type.go
+++ b/pkg/asset/type.go
@@ -12,6 +12,7 @@ type TypeDescription struct {
AllowMultiple bool
GetTitle QueryTypeTitle
ContentType string
+ ContentEncoding string
ReportingPrio int // the smaller, the higher the asset is on the list during reporting
NoReporting bool
customCompressor Compressor
@@ -44,6 +45,7 @@ var assetTypes = map[dashapi.AssetType]*TypeDescription{
GetTitle: constTitle("coverage report(html)"),
AllowMultiple: true,
ContentType: "text/html",
+ ContentEncoding: "gzip", // We do want to decompress than right in the browser.
NoReporting: true,
customCompressor: gzipCompressor,
preserveExtension: true,