summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2025-05-12 15:51:24 +0300
committerthegeorg <[email protected]>2025-05-12 16:06:27 +0300
commitd629bb70c8773d2c0c43f5088ddbb5a86d8c37ea (patch)
tree4f678e0d65ad08c800db21c657d3b0f71fafed06 /contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h
parent92c4b696d7a1c03d54e13aff7a7c20a078d90dd7 (diff)
Update contrib/restricted/aws libraries to nixpkgs 24.05
commit_hash:f8083acb039e6005e820cdee77b84e0a6b6c6d6d
Diffstat (limited to 'contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h')
-rw-r--r--contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h134
1 files changed, 95 insertions, 39 deletions
diff --git a/contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h b/contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h
index 5fe22ff7409..d9c06b8a033 100644
--- a/contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h
+++ b/contrib/restricted/aws/aws-c-s3/include/aws/s3/private/s3_util.h
@@ -24,20 +24,18 @@
#endif
#define KB_TO_BYTES(kb) ((kb)*1024)
#define MB_TO_BYTES(mb) ((mb)*1024 * 1024)
+#define GB_TO_BYTES(gb) ((gb)*1024 * 1024 * 1024ULL)
+
+#define MS_TO_NS(ms) ((uint64_t)(ms)*1000000)
+#define SEC_TO_NS(ms) ((uint64_t)(ms)*1000000000)
struct aws_allocator;
struct aws_http_stream;
struct aws_http_headers;
struct aws_http_message;
-struct aws_event_loop;
-
-enum aws_s3_response_status {
- AWS_S3_RESPONSE_STATUS_SUCCESS = 200,
- AWS_S3_RESPONSE_STATUS_NO_CONTENT_SUCCESS = 204,
- AWS_S3_RESPONSE_STATUS_RANGE_SUCCESS = 206,
- AWS_S3_RESPONSE_STATUS_INTERNAL_ERROR = 500,
- AWS_S3_RESPONSE_STATUS_SLOW_DOWN = 503,
-};
+struct aws_s3_client;
+struct aws_s3_request;
+struct aws_s3_meta_request;
struct aws_cached_signing_config_aws {
struct aws_allocator *allocator;
@@ -111,6 +109,12 @@ AWS_S3_API
extern const struct aws_byte_cursor g_user_agent_header_product_name;
AWS_S3_API
+extern const struct aws_byte_cursor g_user_agent_header_platform;
+
+AWS_S3_API
+extern const struct aws_byte_cursor g_user_agent_header_unknown;
+
+AWS_S3_API
extern const struct aws_byte_cursor g_acl_header_name;
AWS_S3_API
@@ -141,10 +145,15 @@ AWS_S3_API
extern const struct aws_byte_cursor g_s3_service_name;
AWS_S3_API
+extern const struct aws_byte_cursor g_s3express_service_name;
+
+AWS_S3_API
extern const struct aws_byte_cursor g_range_header_name;
extern const struct aws_byte_cursor g_if_match_header_name;
+extern const struct aws_byte_cursor g_request_id_header_name;
+
AWS_S3_API
extern const struct aws_byte_cursor g_content_range_header_name;
@@ -152,6 +161,9 @@ AWS_S3_API
extern const struct aws_byte_cursor g_accept_ranges_header_name;
AWS_S3_API
+extern const struct aws_byte_cursor g_mp_parts_count_header_name;
+
+AWS_S3_API
extern const struct aws_byte_cursor g_post_method;
AWS_S3_API
@@ -160,17 +172,18 @@ extern const struct aws_byte_cursor g_head_method;
AWS_S3_API
extern const struct aws_byte_cursor g_delete_method;
-extern const struct aws_byte_cursor g_error_body_xml_name;
-
-extern const struct aws_byte_cursor g_code_body_xml_name;
-
-extern const struct aws_byte_cursor g_s3_internal_error_code;
-
AWS_S3_API
extern const uint32_t g_s3_max_num_upload_parts;
+/**
+ * Cache and initial the signing config based on the client.
+ *
+ * @param client
+ * @param signing_config
+ * @return struct aws_cached_signing_config_aws*
+ */
struct aws_cached_signing_config_aws *aws_cached_signing_config_new(
- struct aws_allocator *allocator,
+ struct aws_s3_client *client,
const struct aws_signing_config_aws *signing_config);
void aws_cached_signing_config_destroy(struct aws_cached_signing_config_aws *cached_signing_config);
@@ -179,25 +192,35 @@ void aws_cached_signing_config_destroy(struct aws_cached_signing_config_aws *cac
AWS_S3_API
void copy_http_headers(const struct aws_http_headers *src, struct aws_http_headers *dest);
-/* Get a top-level (exists directly under the root tag) tag value. */
-AWS_S3_API
-struct aws_string *aws_xml_get_top_level_tag(
- struct aws_allocator *allocator,
- const struct aws_byte_cursor *tag_name,
- struct aws_byte_cursor *xml_body);
-
-/* Get a top-level (exists directly under the root tag) tag value with expected root name. */
+/**
+ * Get content of XML element at path.
+ *
+ * path_name_array must be a C array of char*, with a NULL as its final entry.
+ *
+ * For example:
+ * Given `xml_doc`: "<Error><Code>SlowDown</Code></Error>"
+ * And `path_name_array`: {"Error", "Code", NULL}
+ * `out_body` will get set to: "SlowDown"
+ *
+ * Returns AWS_OP_SUCCESS or AWS_OP_ERR.
+ * Raises AWS_ERROR_STRING_MATCH_NOT_FOUND if path not found in XML,
+ * or AWS_ERROR_INVALID_XML if the XML can't be parsed.
+ *
+ * DO NOT make this function public without a lot of thought.
+ * The whole thing of passing a C-array of C-strings with a NULL sentinel
+ * is unconventional for this codebase.
+ */
AWS_S3_API
-struct aws_string *aws_xml_get_top_level_tag_with_root_name(
+int aws_xml_get_body_at_path(
struct aws_allocator *allocator,
- const struct aws_byte_cursor *tag_name,
- const struct aws_byte_cursor *expected_root_name,
- bool *out_root_name_mismatch,
- struct aws_byte_cursor *xml_body);
+ struct aws_byte_cursor xml_doc,
+ const char *path_name_array[],
+ struct aws_byte_cursor *out_body);
-/* replace &quot; with escaped /" */
+/* replace &quot; with escaped /"
+ * Returns initialized aws_byte_buf */
AWS_S3_API
-void replace_quote_entities(struct aws_allocator *allocator, struct aws_string *str, struct aws_byte_buf *out_buf);
+struct aws_byte_buf aws_replace_quote_entities(struct aws_allocator *allocator, struct aws_byte_cursor src);
/* strip quotes if string is enclosed in quotes. does not remove quotes if they only appear on either side of the string
*/
@@ -228,27 +251,60 @@ int aws_s3_parse_content_length_response_header(
struct aws_http_headers *response_headers,
uint64_t *out_content_length);
-/* Calculate the number of parts based on overall object-range and part_size. This takes into account aligning
- * part-ranges on part_size. (ie: if object_range_start is not evenly divisible by part_size, it is considered in the
- * middle of a contiguous part, and that first part will be smaller than part_size.) */
+/*
+ * Given the request headers list, finds the Range header and parses the range-start and range-end. All arguments are
+ * required.
+ * */
+AWS_S3_API
+int aws_s3_parse_request_range_header(
+ struct aws_http_headers *request_headers,
+ bool *out_has_start_range,
+ bool *out_has_end_range,
+ uint64_t *out_start_range,
+ uint64_t *out_end_range);
+
+/* Calculate the number of parts based on overall object-range and part_size. */
AWS_S3_API
-uint32_t aws_s3_get_num_parts(size_t part_size, uint64_t object_range_start, uint64_t object_range_end);
+uint32_t aws_s3_calculate_auto_ranged_get_num_parts(
+ size_t part_size,
+ uint64_t first_part_size,
+ uint64_t object_range_start,
+ uint64_t object_range_end);
+
+/**
+ * Calculates the optimal part size and num parts given the 'content_length' and 'client_part_size'.
+ * This will increase the part size to stay within S3's number of parts.
+ * If the required part size exceeds the 'client_max_part_size' or
+ * if the system cannot support the required part size, it will raise an 'AWS_ERROR_INVALID_ARGUMENT' argument.
+ */
+AWS_S3_API
+int aws_s3_calculate_optimal_mpu_part_size_and_num_parts(
+ uint64_t content_length,
+ size_t client_part_size,
+ uint64_t client_max_part_size,
+ size_t *out_part_size,
+ uint32_t *out_num_parts);
/* Calculates the part range for a part given overall object range, size of each part, and the part's number. Note: part
- * numbers begin at one. This takes into account aligning part-ranges on part_size. Intended to be used in conjunction
- * with aws_s3_get_num_parts. part_number should be less than or equal to the result of aws_s3_get_num_parts. */
+ * numbers begin at one. Intended to be used in conjunction
+ * with aws_s3_calculate_auto_ranged_get_num_parts. part_number should be less than or equal to the result of
+ * aws_s3_calculate_auto_ranged_get_num_parts. */
AWS_S3_API
-void aws_s3_get_part_range(
+void aws_s3_calculate_auto_ranged_get_part_range(
uint64_t object_range_start,
uint64_t object_range_end,
size_t part_size,
+ uint64_t first_part_size,
uint32_t part_number,
uint64_t *out_part_range_start,
uint64_t *out_part_range_end);
/* Match the S3 error code to CRT error code, return AWS_ERROR_UNKNOWN when not matched */
AWS_S3_API
-int aws_s3_crt_error_code_from_server_error_code_string(const struct aws_string *error_code_string);
+int aws_s3_crt_error_code_from_server_error_code_string(struct aws_byte_cursor error_code_string);
+
+AWS_S3_API
+void aws_s3_request_finish_up_metrics_synced(struct aws_s3_request *request, struct aws_s3_meta_request *meta_request);
AWS_EXTERN_C_END