diff --git a/source/s3_request_messages.c b/source/s3_request_messages.c index 9e1927912..0551b3a92 100644 --- a/source/s3_request_messages.c +++ b/source/s3_request_messages.c @@ -245,7 +245,7 @@ struct aws_http_message *aws_s3_ranged_get_object_message_new( return message; } -/* Creates a create-multipart-upload request from a given put objet request. */ +/* Creates a create-multipart-upload request from a given put object request. */ struct aws_http_message *aws_s3_create_multipart_upload_message_new( struct aws_allocator *allocator, struct aws_http_message *base_message, @@ -291,6 +291,11 @@ struct aws_http_message *aws_s3_create_multipart_upload_message_new( } } + struct aws_byte_cursor content_length_cursor = aws_byte_cursor_from_c_str("0"); + if (aws_http_headers_set(headers, g_content_length_header_name, content_length_cursor)) { + goto error_clean_up; + } + aws_http_message_set_request_method(message, g_post_method); aws_http_message_set_body_stream(message, NULL); diff --git a/tests/s3_request_messages_tests.c b/tests/s3_request_messages_tests.c index e8f2753a7..01219d16a 100644 --- a/tests/s3_request_messages_tests.c +++ b/tests/s3_request_messages_tests.c @@ -680,14 +680,18 @@ static int s_test_s3_create_multipart_upload_message_new(struct aws_allocator *a ASSERT_SUCCESS(s_test_http_message_request_method(create_multipart_upload_message, "POST")); ASSERT_SUCCESS(s_test_http_message_request_path(create_multipart_upload_message, &expected_create_path)); + + const struct aws_byte_cursor header_exclude_exceptions[] = { + AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("Content-Length"), + }; ASSERT_SUCCESS(s_test_http_headers_match( allocator, original_message, create_multipart_upload_message, g_s3_create_multipart_upload_excluded_headers, g_s3_create_multipart_upload_excluded_headers_count, - NULL, - 0)); + header_exclude_exceptions, + AWS_ARRAY_SIZE(header_exclude_exceptions))); aws_http_message_release(create_multipart_upload_message); aws_http_message_release(original_message);