Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get-object-part #401

Merged
merged 9 commits into from
Dec 28, 2023
Merged

Fix get-object-part #401

merged 9 commits into from
Dec 28, 2023

Conversation

TingDaoK
Copy link
Contributor

Issue #, if available:

  • The "partNumber" is the query parameter instead of header

Description of changes:

  • Properly check for partNumber, use default type if partNumber exist.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c01ebda) 89.05% compared to head (6c347fd) 89.09%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #401      +/-   ##
==========================================
+ Coverage   89.05%   89.09%   +0.03%     
==========================================
  Files          21       21              
  Lines        6160     6170      +10     
==========================================
+ Hits         5486     5497      +11     
+ Misses        674      673       -1     
Files Coverage Δ
source/s3_client.c 88.28% <100.00%> (+0.21%) ⬆️

Comment on lines 1179 to 1180
struct aws_byte_cursor part_number_query_str = aws_byte_cursor_from_c_str("partNumber");
if (aws_byte_cursor_find_exact(&path_and_query, &part_number_query_str, &found_string) ==
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find isn't going to cut it. This would match: "rampartNumbering.s3.us-west-2.amazonaws.com"

I'm sure we have query param helpers somewhere in our codebase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find one, but there is only a uri parsing with query param, which requires the whole uri, I can add something to the uri.h to support it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source/s3_client.c Outdated Show resolved Hide resolved
Comment on lines +1180 to +1196
/* The first split on '?' for path and query is path, the second is query */
if (aws_byte_cursor_next_split(&path_and_query, '?', &sub_string) == true) {
aws_byte_cursor_next_split(&path_and_query, '?', &sub_string);
struct aws_uri_param param;
AWS_ZERO_STRUCT(param);
struct aws_byte_cursor part_number_query_str = aws_byte_cursor_from_c_str("partNumber");
while (aws_query_string_next_param(sub_string, &param)) {
if (aws_byte_cursor_eq(&param.key, &part_number_query_str)) {
return aws_s3_meta_request_default_new(
client->allocator,
client,
AWS_S3_REQUEST_TYPE_GET_OBJECT,
content_length,
false /*should_compute_content_md5*/,
options);
}
}
Copy link
Contributor

@waahm7 waahm7 Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debatable: It would be better to invest in a better helper like aws_http_headers_has/ aws_http_headers_get. This logic will need to be repeated wherever we need to extract a single parameter from query params.

Or, we could still use find and try to locate &partNumber= or ?partNumber=.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong feelings about it.

My take is we are used as a client level http lib, and this is the first time we ever really want to parse the query params, maybe let's hold it back until the next time we want to reuse it?

source/s3_client.c Show resolved Hide resolved
@TingDaoK TingDaoK merged commit 7dd72a9 into main Dec 28, 2023
30 checks passed
@TingDaoK TingDaoK deleted the fix-part branch December 28, 2023 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants