Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Nov 19, 2024
1 parent b83abab commit 945dbef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
3 changes: 0 additions & 3 deletions include/aws/s3/private/s3_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,6 @@ void aws_s3_client_update_upload_part_timeout(
struct aws_s3_request *finished_upload_part_request,
int finished_error_code);

AWS_S3_API
extern struct aws_s3_client_vtable g_s3_client_default_vtable;

AWS_EXTERN_C_END

#endif /* AWS_S3_CLIENT_IMPL_H */
4 changes: 2 additions & 2 deletions source/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static struct aws_s3_meta_request *s_s3_client_meta_request_factory_default(
struct aws_s3_client *client,
const struct aws_s3_meta_request_options *options);

struct aws_s3_client_vtable g_s3_client_default_vtable = {
static struct aws_s3_client_vtable s_s3_client_default_vtable = {
.meta_request_factory = s_s3_client_meta_request_factory_default,
.acquire_http_connection = aws_http_connection_manager_acquire_connection,
.get_host_address_count = aws_host_resolver_get_host_address_count,
Expand Down Expand Up @@ -361,7 +361,7 @@ struct aws_s3_client *aws_s3_client_new(
goto on_error;
}

client->vtable = &g_s3_client_default_vtable;
client->vtable = &s_s3_client_default_vtable;

aws_ref_count_init(&client->ref_count, client, (aws_simple_completion_callback *)s_s3_client_start_destroy);

Expand Down
8 changes: 4 additions & 4 deletions source/s3_meta_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,19 +1056,19 @@ static void s_s3_meta_request_request_on_signed(
metric->time_metrics.sign_end_timestamp_ns - metric->time_metrics.sign_start_timestamp_ns;
}

finish:

/**
* Add the x-amz-content-sha256 header to support trailing checksum.
* Add "x-amz-content-sha256: STREAMING-UNSIGNED-PAYLOAD-TRAILER" header to support trailing checksum.
*/
if (error_code == AWS_ERROR_SUCCESS && request->send_data.require_streaming_unsigned_payload_header) {
if (request->send_data.require_streaming_unsigned_payload_header) {
struct aws_http_headers *headers = aws_http_message_get_headers(request->send_data.message);
error_code = aws_http_headers_set(
headers,
aws_byte_cursor_from_c_str("x-amz-content-sha256"),
g_aws_signed_body_value_streaming_unsigned_payload_trailer);
}

finish:

if (error_code != AWS_ERROR_SUCCESS) {

AWS_LOGF_ERROR(
Expand Down
19 changes: 11 additions & 8 deletions tests/s3_mock_server_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ struct aws_http_stream *s_get_requests_header_make_request(
return stream;
}

/**
* Note: currently (Nov, 2024), S3 don't support create multipart upload anonymously.
*/
TEST_CASE(multipart_upload_unsigned_with_trailer_checksum_mock_server) {
(void)ctx;

Expand All @@ -223,12 +226,12 @@ TEST_CASE(multipart_upload_unsigned_with_trailer_checksum_mock_server) {
};

ASSERT_SUCCESS(aws_s3_tester_bind_client(&tester, &client_config, AWS_S3_TESTER_BIND_CLIENT_REGION));

struct aws_s3_client_vtable s3_client_get_requests_header_vtable = g_s3_client_default_vtable;
s3_client_get_requests_header_vtable.http_connection_make_request = s_get_requests_header_make_request;
struct aws_s3_client *client = aws_s3_client_new(allocator, &client_config);
ASSERT_NOT_NULL(client);
client->vtable = &s3_client_get_requests_header_vtable;

/* Patch the client vtable to record the request header */
struct aws_s3_client_vtable *s3_client_get_requests_header_vtable = client->vtable;
s3_client_get_requests_header_vtable->http_connection_make_request = s_get_requests_header_make_request;

struct aws_byte_cursor object_path = aws_byte_cursor_from_c_str("/default");

Expand Down Expand Up @@ -311,12 +314,12 @@ TEST_CASE(single_upload_unsigned_with_trailer_checksum_mock_server) {
};

ASSERT_SUCCESS(aws_s3_tester_bind_client(&tester, &client_config, AWS_S3_TESTER_BIND_CLIENT_REGION));

struct aws_s3_client_vtable s3_client_get_requests_header_vtable = g_s3_client_default_vtable;
s3_client_get_requests_header_vtable.http_connection_make_request = s_get_requests_header_make_request;
struct aws_s3_client *client = aws_s3_client_new(allocator, &client_config);
ASSERT_NOT_NULL(client);
client->vtable = &s3_client_get_requests_header_vtable;

/* Patch the client vtable to record the request header */
struct aws_s3_client_vtable *s3_client_get_requests_header_vtable = client->vtable;
s3_client_get_requests_header_vtable->http_connection_make_request = s_get_requests_header_make_request;

struct aws_byte_cursor object_path = aws_byte_cursor_from_c_str("/default");

Expand Down

0 comments on commit 945dbef

Please sign in to comment.