From 9be4bbbed44e4182da550a94f987e075aa104285 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 27 Jan 2022 16:37:43 +0300 Subject: [PATCH] [#312] Support Expires and Cache-Control headers Signed-off-by: Denis Kirillov --- api/handler/get.go | 7 +++++++ api/handler/put.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/api/handler/get.go b/api/handler/get.go index 1a910a0..5452504 100644 --- a/api/handler/get.go +++ b/api/handler/get.go @@ -85,6 +85,13 @@ func writeHeaders(h http.Header, info *data.ObjectInfo, tagSetLength int) { h.Set(api.AmzVersionID, info.ID.String()) h.Set(api.AmzTaggingCount, strconv.Itoa(tagSetLength)) + if cacheControl := info.Headers[api.CacheControl]; cacheControl != "" { + h.Set(api.CacheControl, cacheControl) + } + if expires := info.Headers[api.Expires]; expires != "" { + h.Set(api.Expires, expires) + } + for key, val := range info.Headers { if layer.IsSystemHeader(key) { continue diff --git a/api/handler/put.go b/api/handler/put.go index 0bd1f60..44b7b50 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -194,6 +194,12 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) { if contentType := r.Header.Get(api.ContentType); len(contentType) > 0 { metadata[api.ContentType] = contentType } + if cacheControl := r.Header.Get(api.CacheControl); len(cacheControl) > 0 { + metadata[api.CacheControl] = cacheControl + } + if expires := r.Header.Get(api.Expires); len(expires) > 0 { + metadata[api.Expires] = expires + } params := &layer.PutObjectParams{ Bucket: reqInfo.BucketName,