api: Set content-encoding properly if set. (#2245)

Additionally don't set content-type if not present, golang http
server automaticaly handles this and sets it automatically.
This commit is contained in:
Harshavardhana
2016-07-20 12:40:20 -07:00
committed by GitHub
parent 18728a0b59
commit c1e953b368
5 changed files with 34 additions and 14 deletions

View File

@@ -23,7 +23,6 @@ import (
"net/http"
"runtime"
"strconv"
"strings"
)
//// helpers
@@ -67,16 +66,18 @@ func setObjectHeaders(w http.ResponseWriter, objInfo ObjectInfo, contentRange *h
lastModified := objInfo.ModTime.UTC().Format(http.TimeFormat)
w.Header().Set("Last-Modified", lastModified)
w.Header().Set("Content-Type", objInfo.ContentType)
if objInfo.ContentType != "" {
w.Header().Set("Content-Type", objInfo.ContentType)
}
if objInfo.MD5Sum != "" {
w.Header().Set("ETag", "\""+objInfo.MD5Sum+"\"")
}
if objInfo.ContentEncoding != "" {
w.Header().Set("Content-Encoding", objInfo.ContentEncoding)
}
w.Header().Set("Content-Length", strconv.FormatInt(objInfo.Size, 10))
for k, v := range objInfo.UserDefined {
if strings.HasPrefix(k, "X-Amz-Meta-") {
w.Header().Set(k, v)
}
w.Header().Set(k, v)
}
// for providing ranged content