@@ -369,6 +369,25 @@ inline bool str_has_cntrl(const char* s) {
369369 return str_has_cntrl (_s);
370370}
371371
372+ // remove any aws-chunked entries from the comma-separated list
373+ static std::string content_encoding_without_aws_chunked (std::string_view value)
374+ {
375+ std::string result;
376+ result.reserve (value.size ());
377+
378+ for (std::string_view part : ceph::split (value, " , " )) {
379+ if (part == " aws-chunked" ) {
380+ continue ;
381+ }
382+ if (!result.empty ()) {
383+ result += " , " ;
384+ }
385+ result += part;
386+ }
387+
388+ return result;
389+ }
390+
372391int RGWGetObj_ObjStore_S3::send_response_data (bufferlist& bl, off_t bl_ofs,
373392 off_t bl_len)
374393{
@@ -652,7 +671,20 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
652671 --len;
653672 s.resize (len);
654673 }
655- response_attrs[aiter->second ] = s;
674+
675+ if (aiter->first == RGW_ATTR_CONTENT_ENC) {
676+ // Amazon S3 stores the resulting object without the aws-chunked
677+ // value in the content-encoding header. If aws-chunked is the only
678+ // value that you pass in the content-encoding header, S3 considers
679+ // the content-encoding header empty and does not return this header
680+ // when your retrieve the object.
681+ std::string encoding = content_encoding_without_aws_chunked (s);
682+ if (!encoding.empty ()) {
683+ response_attrs[aiter->second ] = std::move (encoding);
684+ }
685+ } else {
686+ response_attrs[aiter->second ] = std::move (s);
687+ }
656688 }
657689 } else if (iter->first .compare (RGW_ATTR_CONTENT_TYPE) == 0 ) {
658690 /* Special handling for content_type. */
0 commit comments