Skip to content

Commit e3fd70b

Browse files
committed
default request without body
1 parent 5eac79f commit e3fd70b

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

source/s3_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ static struct aws_s3_meta_request *s_s3_client_meta_request_factory_default(
12361236
client->allocator,
12371237
client,
12381238
AWS_S3_REQUEST_TYPE_GET_OBJECT,
1239-
content_length,
1239+
0, /* Content length for request */
12401240
false /*should_compute_content_md5*/,
12411241
options);
12421242
}

source/s3_default_meta_request.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static void s_s3_default_prepare_request_finish(
329329

330330
struct aws_s3_request *request = request_prep->request;
331331
struct aws_s3_meta_request *meta_request = request->meta_request;
332+
struct aws_s3_meta_request_default *meta_request_default = meta_request->impl;
332333

333334
if (error_code != AWS_ERROR_SUCCESS) {
334335
goto finish;
@@ -347,13 +348,17 @@ static void s_s3_default_prepare_request_finish(
347348
struct aws_http_headers *headers = aws_http_message_get_headers(message);
348349
aws_http_headers_set(headers, g_request_validation_mode, g_enabled);
349350
}
350-
aws_s3_message_util_assign_body(
351-
meta_request->allocator,
352-
&request->request_body,
353-
message,
354-
&meta_request->checksum_config,
355-
NULL /* out_checksum */);
356-
351+
if (meta_request_default->request_type == AWS_S3_REQUEST_TYPE_PUT_OBJECT ||
352+
meta_request_default->request_type == AWS_S3_REQUEST_TYPE_UPLOAD_PART || request->request_body.len > 0) {
353+
/* Only PUT Object and Upload part support trailing checksum, that needs the special encoding even if the body
354+
* has 0 length. */
355+
aws_s3_message_util_assign_body(
356+
meta_request->allocator,
357+
&request->request_body,
358+
message,
359+
&meta_request->checksum_config,
360+
NULL /* out_checksum */);
361+
}
357362
aws_s3_request_setup_send_data(request, message);
358363

359364
aws_http_message_release(message);

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ add_net_test_case(test_s3_round_trip)
176176
add_net_test_case(test_s3_round_trip_default_get)
177177
add_net_test_case(test_s3_round_trip_multipart_get_fc)
178178
add_net_test_case(test_s3_round_trip_default_get_fc)
179+
add_net_test_case(test_s3_round_trip_empty_fc)
179180
add_net_test_case(test_s3_round_trip_mpu_multipart_get_fc)
180181
add_net_test_case(test_s3_round_trip_mpu_multipart_get_with_list_algorithm_fc)
181182
add_net_test_case(test_s3_round_trip_mpu_default_get_fc)

tests/s3_data_plane_tests.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,6 +3922,7 @@ static int s_test_s3_round_trip_default_get_fc_helper(
39223922
struct aws_allocator *allocator,
39233923
void *ctx,
39243924
bool via_header,
3925+
uint32_t object_size_mb,
39253926
enum aws_s3_tester_full_object_checksum full_object_checksum) {
39263927
(void)ctx;
39273928

@@ -3943,8 +3944,9 @@ static int s_test_s3_round_trip_default_get_fc_helper(
39433944
snprintf(
39443945
object_path_sprintf_buffer,
39453946
sizeof(object_path_sprintf_buffer),
3946-
"/prefix/round_trip/test_default_fc_%d.txt",
3947-
algorithm);
3947+
"/prefix/round_trip/test_default_fc_%d_%d.txt",
3948+
algorithm,
3949+
object_size_mb);
39483950

39493951
ASSERT_SUCCESS(aws_s3_tester_upload_file_path_init(
39503952
allocator, &path_buf, aws_byte_cursor_from_c_str(object_path_sprintf_buffer)));
@@ -3960,7 +3962,7 @@ static int s_test_s3_round_trip_default_get_fc_helper(
39603962
.checksum_via_header = via_header,
39613963
.put_options =
39623964
{
3963-
.object_size_mb = 1,
3965+
.object_size_mb = object_size_mb,
39643966
.object_path_override = object_path,
39653967
},
39663968
};
@@ -4000,18 +4002,22 @@ static int s_test_s3_round_trip_default_get_fc_helper(
40004002

40014003
AWS_TEST_CASE(test_s3_round_trip_default_get_fc, s_test_s3_round_trip_default_get_fc)
40024004
static int s_test_s3_round_trip_default_get_fc(struct aws_allocator *allocator, void *ctx) {
4003-
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, false, AWS_TEST_FOC_NONE);
4005+
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, false, 1 /*object_size_mb*/, AWS_TEST_FOC_NONE);
4006+
}
4007+
AWS_TEST_CASE(test_s3_round_trip_empty_fc, s_test_s3_round_trip_empty_fc)
4008+
static int s_test_s3_round_trip_empty_fc(struct aws_allocator *allocator, void *ctx) {
4009+
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, false, 0, AWS_TEST_FOC_NONE);
40044010
}
40054011

40064012
AWS_TEST_CASE(test_s3_round_trip_default_get_fc_header, s_test_s3_round_trip_default_get_fc_header)
40074013
static int s_test_s3_round_trip_default_get_fc_header(struct aws_allocator *allocator, void *ctx) {
4008-
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, true, AWS_TEST_FOC_NONE);
4014+
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, true, 1, AWS_TEST_FOC_NONE);
40094015
}
40104016
AWS_TEST_CASE(
40114017
test_s3_round_trip_default_get_full_object_checksum_fc,
40124018
s_test_s3_round_trip_default_get_full_object_checksum_fc)
40134019
static int s_test_s3_round_trip_default_get_full_object_checksum_fc(struct aws_allocator *allocator, void *ctx) {
4014-
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, false, AWS_TEST_FOC_HEADER);
4020+
return s_test_s3_round_trip_default_get_fc_helper(allocator, ctx, false, 1, AWS_TEST_FOC_HEADER);
40154021
}
40164022

40174023
static int s_test_s3_round_trip_multipart_get_fc_helper(struct aws_allocator *allocator, void *ctx, bool via_header) {

0 commit comments

Comments
 (0)