Skip to content

Commit

Permalink
Remove Populating Empty Error Body (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 authored Oct 31, 2023
1 parent ecaf3f7 commit f354c53
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
10 changes: 0 additions & 10 deletions source/s3_meta_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1779,16 +1779,6 @@ void aws_s3_meta_request_result_setup(

aws_byte_buf_init_copy(
result->error_response_body, meta_request->allocator, &failed_request->send_data.response_body);
} else if (error_code == AWS_ERROR_S3_INVALID_RESPONSE_STATUS) {
/* Sometimes S3 does not send an error explanation in the body such as if the HEAD_OBJECT request fails.
* Populate the error_response with aws_http_status_text to have something reasonable instead of
* empty error_response_body
*/
result->error_response_body = aws_mem_calloc(meta_request->allocator, 1, sizeof(struct aws_byte_buf));
aws_byte_buf_init_copy_from_cursor(
result->error_response_body,
meta_request->allocator,
aws_byte_cursor_from_c_str(aws_http_status_text(response_status)));
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ add_net_test_case(test_s3_meta_request_default)
add_net_test_case(test_s3_put_object_fail_headers_callback)
add_net_test_case(test_s3_put_object_fail_body_callback)
add_net_test_case(test_s3_get_object_fail_headers_callback)
add_net_test_case(test_s3_get_object_fail_key_does_not_exist)
add_net_test_case(test_s3_get_object_fail_body_callback)
add_net_test_case(test_s3_default_fail_headers_callback)
add_net_test_case(test_s3_default_invoke_headers_callback_on_error)
Expand Down
27 changes: 0 additions & 27 deletions tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4225,33 +4225,6 @@ static int s_test_s3_get_object_fail_headers_callback(struct aws_allocator *allo
return 0;
}

AWS_TEST_CASE(test_s3_get_object_fail_key_does_not_exist, s_test_s3_get_object_fail_key_does_not_exist)
static int s_test_s3_get_object_fail_key_does_not_exist(struct aws_allocator *allocator, void *ctx) {
(void)ctx;

struct aws_s3_meta_request_test_results meta_request_test_results;
aws_s3_meta_request_test_results_init(&meta_request_test_results, allocator);

struct aws_s3_tester_meta_request_options options = {
.allocator = allocator,
.meta_request_type = AWS_S3_META_REQUEST_TYPE_GET_OBJECT,
.validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_FAILURE,
.validate_get_response_checksum = true,
.get_options =
{
.object_path = aws_byte_cursor_from_c_str("/does_not_exist"),
},
};

ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(NULL, &options, &meta_request_test_results));
ASSERT_INT_EQUALS(meta_request_test_results.finished_error_code, AWS_ERROR_S3_INVALID_RESPONSE_STATUS);
ASSERT_CURSOR_VALUE_CSTRING_EQUALS(
aws_byte_cursor_from_buf(&meta_request_test_results.error_response_body), "Not Found");
aws_s3_meta_request_test_results_clean_up(&meta_request_test_results);

return 0;
}

AWS_TEST_CASE(test_s3_get_object_fail_body_callback, s_test_s3_get_object_fail_body_callback)
static int s_test_s3_get_object_fail_body_callback(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
Expand Down

0 comments on commit f354c53

Please sign in to comment.