@@ -22,13 +22,9 @@ const struct aws_byte_cursor g_s3_create_multipart_upload_excluded_headers[] = {
2222 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("Content-MD5" ),
2323 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-copy-source" ),
2424 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-copy-source-range" ),
25- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-crc64nvme" ),
26- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-crc32c" ),
27- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-crc32" ),
28- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-sha1" ),
29- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-sha256" ),
3025 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("if-none-match" ),
3126 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-create-session-mode" ),
27+ AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-sdk-checksum-algorithm" ),
3228};
3329
3430const size_t g_s3_create_multipart_upload_excluded_headers_count =
@@ -58,11 +54,6 @@ const struct aws_byte_cursor g_s3_upload_part_excluded_headers[] = {
5854 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-object-lock-mode" ),
5955 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-object-lock-retain-until-date" ),
6056 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-object-lock-legal-hold" ),
61- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-crc64nvme" ),
62- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-crc32c" ),
63- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-crc32" ),
64- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-sha1" ),
65- AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-sha256" ),
6657 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("if-none-match" ),
6758 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-create-session-mode" ),
6859};
@@ -248,6 +239,7 @@ const struct aws_byte_cursor g_s3_create_session_allowed_headers[] = {
248239const size_t g_s3_create_session_allowed_headers_count = AWS_ARRAY_SIZE (g_s3_create_session_allowed_headers );
249240
250241static const struct aws_byte_cursor s_x_amz_meta_prefix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-meta-" );
242+ static const struct aws_byte_cursor s_x_amz_checksum_prefix = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-" );
251243
252244static const struct aws_byte_cursor s_checksum_type_header =
253245 AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("x-amz-checksum-type" );
@@ -299,7 +291,8 @@ struct aws_http_message *aws_s3_create_multipart_upload_message_new(
299291 base_message ,
300292 g_s3_create_multipart_upload_excluded_headers ,
301293 AWS_ARRAY_SIZE (g_s3_create_multipart_upload_excluded_headers ),
302- false /*exclude_x_amz_meta*/ );
294+ false /*exclude_x_amz_meta*/ ,
295+ true /*exclude_x_checksum_meta*/ );
303296
304297 if (message == NULL ) {
305298 return NULL ;
@@ -322,7 +315,12 @@ struct aws_http_message *aws_s3_create_multipart_upload_message_new(
322315 }
323316
324317 if (checksum_config && (checksum_config -> location != AWS_SCL_NONE || checksum_config -> has_full_object_checksum )) {
325- if (checksum_config -> checksum_algorithm ) {
318+ if (checksum_config -> checksum_algorithm == AWS_SCA_UNKNOWN ) {
319+ struct aws_byte_cursor checksum_name = aws_byte_cursor_from_buf (& checksum_config -> unknown_checksum_algo );
320+ if (aws_http_headers_set (headers , g_checksum_algorithm_header_name , checksum_name )) {
321+ goto error_clean_up ;
322+ }
323+ } else if (checksum_config -> checksum_algorithm ) {
326324 if (aws_http_headers_set (
327325 headers ,
328326 g_checksum_algorithm_header_name ,
@@ -374,7 +372,8 @@ struct aws_http_message *aws_s3_upload_part_message_new_streaming(
374372 base_message ,
375373 g_s3_upload_part_excluded_headers ,
376374 AWS_ARRAY_SIZE (g_s3_upload_part_excluded_headers ),
377- true /*exclude_x_amz_meta*/ );
375+ true /*exclude_x_amz_meta*/ ,
376+ true /*exclude_x_checksum_meta*/ );
378377
379378 if (message == NULL ) {
380379 return NULL ;
@@ -429,7 +428,8 @@ struct aws_http_message *aws_s3_upload_part_message_new(
429428 base_message ,
430429 g_s3_upload_part_excluded_headers ,
431430 AWS_ARRAY_SIZE (g_s3_upload_part_excluded_headers ),
432- true /*exclude_x_amz_meta*/ );
431+ true /*exclude_x_amz_meta*/ ,
432+ true /*exclude_x_checksum_meta*/ );
433433
434434 if (message == NULL ) {
435435 return NULL ;
@@ -477,7 +477,8 @@ struct aws_http_message *aws_s3_upload_part_copy_message_new(
477477 base_message ,
478478 g_s3_upload_part_excluded_headers ,
479479 AWS_ARRAY_SIZE (g_s3_upload_part_excluded_headers ),
480- true /*exclude_x_amz_meta*/ );
480+ true /*exclude_x_amz_meta*/ ,
481+ true /*exclude_x_checksum_meta*/ );
481482
482483 if (message == NULL ) {
483484 goto error_clean_up ;
@@ -706,15 +707,17 @@ struct aws_http_message *aws_s3_complete_multipart_message_new(
706707 base_message ,
707708 g_s3_complete_multipart_upload_with_checksum_excluded_headers ,
708709 AWS_ARRAY_SIZE (g_s3_complete_multipart_upload_with_checksum_excluded_headers ),
709- true /*exclude_x_amz_meta*/ );
710+ true /*exclude_x_amz_meta*/ ,
711+ false /*exclude_x_checksum_meta*/ );
710712
711713 } else {
712714 message = aws_s3_message_util_copy_http_message_no_body_filter_headers (
713715 allocator ,
714716 base_message ,
715717 g_s3_complete_multipart_upload_excluded_headers ,
716718 AWS_ARRAY_SIZE (g_s3_complete_multipart_upload_excluded_headers ),
717- true /*exclude_x_amz_meta*/ );
719+ true /*exclude_x_amz_meta*/ ,
720+ false /*exclude_x_checksum_meta*/ );
718721 }
719722
720723 struct aws_http_headers * headers = NULL ;
@@ -863,7 +866,8 @@ struct aws_http_message *aws_s3_abort_multipart_upload_message_new(
863866 base_message ,
864867 g_s3_abort_multipart_upload_excluded_headers ,
865868 AWS_ARRAY_SIZE (g_s3_abort_multipart_upload_excluded_headers ),
866- true /*exclude_x_amz_meta*/ );
869+ true /*exclude_x_amz_meta*/ ,
870+ true /*exclude_x_checksum_meta*/ );
867871
868872 if (aws_s3_message_util_set_multipart_request_path (allocator , upload_id , 0 , false, message )) {
869873 goto error_clean_up ;
@@ -1141,15 +1145,16 @@ struct aws_http_message *aws_s3_message_util_copy_http_message_no_body_all_heade
11411145 struct aws_allocator * allocator ,
11421146 struct aws_http_message * base_message ) {
11431147
1144- return aws_s3_message_util_copy_http_message_no_body_filter_headers (allocator , base_message , NULL , 0 , false);
1148+ return aws_s3_message_util_copy_http_message_no_body_filter_headers (allocator , base_message , NULL , 0 , false, false );
11451149}
11461150
11471151struct aws_http_message * aws_s3_message_util_copy_http_message_no_body_filter_headers (
11481152 struct aws_allocator * allocator ,
11491153 struct aws_http_message * base_message ,
11501154 const struct aws_byte_cursor * excluded_header_array ,
11511155 size_t excluded_header_array_size ,
1152- bool exclude_x_amz_meta ) {
1156+ bool exclude_x_amz_meta ,
1157+ bool exclude_x_amz_checksum ) {
11531158
11541159 AWS_PRECONDITION (allocator );
11551160 AWS_PRECONDITION (base_message );
@@ -1178,7 +1183,12 @@ struct aws_http_message *aws_s3_message_util_copy_http_message_no_body_filter_he
11781183 }
11791184
11801185 aws_s3_message_util_copy_headers (
1181- base_message , message , excluded_header_array , excluded_header_array_size , exclude_x_amz_meta );
1186+ base_message ,
1187+ message ,
1188+ excluded_header_array ,
1189+ excluded_header_array_size ,
1190+ exclude_x_amz_meta ,
1191+ exclude_x_amz_checksum );
11821192
11831193 return message ;
11841194
@@ -1192,7 +1202,8 @@ void aws_s3_message_util_copy_headers(
11921202 struct aws_http_message * dest_message ,
11931203 const struct aws_byte_cursor * excluded_header_array ,
11941204 size_t excluded_header_array_size ,
1195- bool exclude_x_amz_meta ) {
1205+ bool exclude_x_amz_meta ,
1206+ bool exclude_x_amz_checksum ) {
11961207
11971208 size_t num_headers = aws_http_message_get_header_count (source_message );
11981209
@@ -1222,6 +1233,12 @@ void aws_s3_message_util_copy_headers(
12221233 }
12231234 }
12241235
1236+ if (exclude_x_amz_checksum ) {
1237+ if (aws_byte_cursor_starts_with_ignore_case (& header .name , & s_x_amz_checksum_prefix )) {
1238+ continue ;
1239+ }
1240+ }
1241+
12251242 error |= aws_http_message_add_header (dest_message , header );
12261243 (void )error ;
12271244 AWS_ASSERT (!error );
0 commit comments