diff --git a/api/handler/get.go b/api/handler/get.go index 86d5b9c2..425a0d6d 100644 --- a/api/handler/get.go +++ b/api/handler/get.go @@ -110,6 +110,9 @@ func writeHeaders(h http.Header, requestHeader http.Header, extendedInfo *data.E if encodings := info.Headers[api.ContentEncoding]; encodings != "" { h.Set(api.ContentEncoding, encodings) } + if contentLanguage := info.Headers[api.ContentLanguage]; contentLanguage != "" { + h.Set(api.ContentLanguage, contentLanguage) + } for key, val := range info.Headers { if layer.IsSystemHeader(key) { diff --git a/api/handler/multipart_upload.go b/api/handler/multipart_upload.go index b8694170..e3cefbd5 100644 --- a/api/handler/multipart_upload.go +++ b/api/handler/multipart_upload.go @@ -154,6 +154,9 @@ func (h *handler) CreateMultipartUploadHandler(w http.ResponseWriter, r *http.Re if contentType := r.Header.Get(api.ContentType); len(contentType) > 0 { p.Header[api.ContentType] = contentType } + if contentLanguage := r.Header.Get(api.ContentLanguage); len(contentLanguage) > 0 { + p.Header[api.ContentLanguage] = contentLanguage + } p.CopiesNumbers, err = h.pickCopiesNumbers(p.Header, bktInfo.LocationConstraint) if err != nil { diff --git a/api/handler/multipart_upload_test.go b/api/handler/multipart_upload_test.go index 16921c8b..15350967 100644 --- a/api/handler/multipart_upload_test.go +++ b/api/handler/multipart_upload_test.go @@ -253,6 +253,29 @@ func TestListParts(t *testing.T) { require.Len(t, list.Parts, 0) } +func TestMultipartUploadWithContentLanguage(t *testing.T) { + hc := prepareHandlerContext(t) + + bktName, objName := "bucket-1", "object-1" + createTestBucket(hc, bktName) + + partSize := 5 * 1024 * 1024 + exceptedContentLanguage := "en" + headers := map[string]string{ + api.ContentLanguage: exceptedContentLanguage, + } + + multipartUpload := createMultipartUpload(hc, bktName, objName, headers) + etag1, _ := uploadPart(hc, bktName, objName, multipartUpload.UploadID, 1, partSize) + etag2, _ := uploadPart(hc, bktName, objName, multipartUpload.UploadID, 2, partSize) + w := completeMultipartUploadBase(hc, bktName, objName, multipartUpload.UploadID, []string{etag1, etag2}) + assertStatus(t, w, http.StatusOK) + + w, r := prepareTestRequest(hc, bktName, objName, nil) + hc.Handler().HeadObjectHandler(w, r) + require.Equal(t, exceptedContentLanguage, w.Header().Get(api.ContentLanguage)) +} + func uploadPartCopy(hc *handlerContext, bktName, objName, uploadID string, num int, srcObj string, start, end int) *UploadPartCopyResponse { return uploadPartCopyBase(hc, bktName, objName, false, uploadID, num, srcObj, start, end) } diff --git a/api/handler/put.go b/api/handler/put.go index 9262d0d2..048bb213 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -214,6 +214,9 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) { if expires := r.Header.Get(api.Expires); len(expires) > 0 { metadata[api.Expires] = expires } + if contentLanguage := r.Header.Get(api.ContentLanguage); len(contentLanguage) > 0 { + metadata[api.ContentLanguage] = contentLanguage + } encryptionParams, err := formEncryptionParams(r) if err != nil { diff --git a/api/handler/put_test.go b/api/handler/put_test.go index b1d0bf14..fb964b9d 100644 --- a/api/handler/put_test.go +++ b/api/handler/put_test.go @@ -344,3 +344,18 @@ func getObjectAttribute(obj *object.Object, attrName string) string { } return "" } + +func TestPutObjectWithContentLanguage(t *testing.T) { + tc := prepareHandlerContext(t) + + exceptedContentLanguage := "en" + bktName, objName := "bucket-1", "object-1" + createTestBucket(tc, bktName) + + w, r := prepareTestRequest(tc, bktName, objName, nil) + r.Header.Set(api.ContentLanguage, exceptedContentLanguage) + tc.Handler().PutObjectHandler(w, r) + + tc.Handler().HeadObjectHandler(w, r) + require.Equal(t, exceptedContentLanguage, w.Header().Get(api.ContentLanguage)) +} diff --git a/api/headers.go b/api/headers.go index 7e99a12b..bbffc24a 100644 --- a/api/headers.go +++ b/api/headers.go @@ -114,6 +114,7 @@ var SystemMetadata = map[string]struct{}{ ContentType: {}, LastModified: {}, ETag: {}, + ContentLanguage: {}, } func IsSignedStreamingV4(r *http.Request) bool {