-
Notifications
You must be signed in to change notification settings - Fork 40
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
Improve Copy Operation by taking the Source URI #482
Changes from 18 commits
70a3500
0f22881
9f4968a
0834c76
0e07307
b95629c
ef440b8
452f6c0
a0ddeb8
eea085a
bcf9686
8f65026
6852ff4
81e91a8
cc8c865
5f20277
bb15afd
d01fab7
96e1ab2
a2a911c
5121ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#include <aws/common/byte_buf.h> | ||
#include <aws/common/encoding.h> | ||
#include <aws/common/string.h> | ||
#include <aws/common/uri.h> | ||
#include <aws/http/request_response.h> | ||
#include <aws/io/async_stream.h> | ||
#include <aws/io/stream.h> | ||
|
@@ -457,8 +458,37 @@ static const struct aws_byte_cursor s_slash_char = AWS_BYTE_CUR_INIT_FROM_STRING | |
*/ | ||
struct aws_http_message *aws_s3_get_source_object_size_message_new( | ||
struct aws_allocator *allocator, | ||
struct aws_http_message *base_message) { | ||
struct aws_http_message *base_message, | ||
struct aws_uri *source_uri) { | ||
struct aws_http_message *message = NULL; | ||
|
||
message = aws_http_message_new_request(allocator); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lot of the error handling down there assumes there was nothing to clean up and just returns null. Need to update them since we now allocate the message at the beginning of the function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, updated. |
||
if (message == NULL) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to worry about the signing region here today as well? or we are keeping the source must be in the same region as dest behavior? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. For now, I have updated the docs to mention that only limitations 1 and 2 will be bypassed using URI. |
||
goto error_cleanup; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, fixed. |
||
} | ||
|
||
if (aws_http_message_set_request_method(message, g_head_method)) { | ||
goto error_cleanup; | ||
} | ||
if (source_uri != NULL && source_uri->self_size > 0) { | ||
/* Parse source host header and path from the provided URI */ | ||
struct aws_byte_cursor host = *aws_uri_host_name(source_uri); | ||
struct aws_byte_cursor path = *aws_uri_path(source_uri); | ||
struct aws_http_header host_header = { | ||
.name = g_host_header_name, | ||
.value = host, | ||
}; | ||
if (aws_http_message_add_header(message, host_header)) { | ||
goto error_cleanup; | ||
} | ||
|
||
if (aws_http_message_set_request_path(message, path)) { | ||
goto error_cleanup; | ||
} | ||
return message; | ||
} | ||
|
||
/* Parse the source host header and path from the x-amz-copy-source header and the destination URI */ | ||
struct aws_byte_buf head_object_host_header; | ||
AWS_ZERO_STRUCT(head_object_host_header); | ||
|
||
|
@@ -529,15 +559,6 @@ struct aws_http_message *aws_s3_get_source_object_size_message_new( | |
goto error_cleanup; | ||
} | ||
|
||
message = aws_http_message_new_request(allocator); | ||
if (message == NULL) { | ||
goto error_cleanup; | ||
} | ||
|
||
if (aws_http_message_set_request_method(message, g_head_method)) { | ||
goto error_cleanup; | ||
} | ||
|
||
struct aws_http_header host_header = { | ||
.name = g_host_header_name, | ||
.value = aws_byte_cursor_from_buf(&head_object_host_header), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
copy_object->synced_data.part_list
was initialized above, it needs to be cleaned up here.Or move the initialization of the list after anything can fail
We could add a simple test to pass in an invalid URI to add a bit more test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch. Fixed with a test.