@@ -160,6 +160,23 @@ extern const double g_default_throughput_target_gbps;
160160
161161AWS_S3_API
162162extern const uint64_t g_streaming_object_size_threshold ;
163+
164+ AWS_S3_API
165+ extern const uint64_t g_default_part_size_fallback ;
166+
167+ AWS_S3_API
168+ extern const uint64_t g_default_max_part_size ;
169+
170+ AWS_S3_API
171+ extern const uint64_t g_s3_optimal_range_size_alignment ;
172+
173+ AWS_S3_API
174+ extern const uint32_t g_s3express_connection_limitation ;
175+ AWS_S3_API
176+ extern const uint64_t g_s3express_connection_limitation_part_size_threshold ;
177+ AWS_S3_API
178+ extern const uint64_t g_s3express_connection_limitation_object_size_threshold ;
179+
163180/**
164181 * Returns AWS_S3_REQUEST_TYPE_UNKNOWN if name doesn't map to an enum value.
165182 */
@@ -240,12 +257,20 @@ void aws_s3_add_user_agent_header(struct aws_allocator *allocator, struct aws_ht
240257 * object-size. All output arguments are optional.*/
241258AWS_S3_API
242259int aws_s3_parse_content_range_response_header (
243- struct aws_allocator * allocator ,
244260 struct aws_http_headers * response_headers ,
245261 uint64_t * out_range_start ,
246262 uint64_t * out_range_end ,
247263 uint64_t * out_object_size );
248264
265+ /* Given a Content-Range header value as a byte cursor, parses the range-start, range-end and
266+ * object-size. All output arguments are optional. */
267+ AWS_S3_API
268+ int aws_s3_parse_content_range_cursor (
269+ struct aws_byte_cursor content_range_cursor ,
270+ uint64_t * out_range_start ,
271+ uint64_t * out_range_end ,
272+ uint64_t * out_object_size );
273+
249274/* Given response headers, parses the content-length from a content-length response header.*/
250275AWS_S3_API
251276int aws_s3_parse_content_length_response_header (
@@ -318,6 +343,53 @@ int aws_s3_check_headers_for_checksum(
318343 struct aws_byte_buf * out_checksum_buffer ,
319344 bool meta_request_level );
320345
346+ /**
347+ * Calculate client-level optimal range size based on memory and connection constraints.
348+ * This function is called during client initialization to determine the base range size
349+ * using the formula: MemoryLimit / concurrency / divisor.
350+ * The result is rounded up to ensure proper alignment and applies minimum size constraints.
351+ *
352+ * @param memory_limit_in_bytes Total memory limit available for buffering
353+ * @param max_connections Maximum number of concurrent connections
354+ * @param out_client_optimal_range_size Output parameter for calculated client-level optimal range size
355+ * @return AWS_OP_SUCCESS on success, AWS_OP_ERR on failure (caller should fall back to default)
356+ */
357+ AWS_S3_API
358+ int aws_s3_calculate_client_optimal_range_size (
359+ uint64_t memory_limit_in_bytes ,
360+ uint32_t max_connections ,
361+ uint64_t * out_client_optimal_range_size );
362+
363+ /**
364+ * Calculate request-level optimal range size by considering object-specific information.
365+ * This function is called per request to adjust the client-level range size based on
366+ * estimated object stored part size using: min(client_optimal_range_size, estimated_object_stored_part_size).
367+ *
368+ * @param client_optimal_range_size The client-level optimal range size from initialization
369+ * @param estimated_object_stored_part_size Estimated size of object stored parts in S3
370+ * @param is_express If the request is a s3express request or not.
371+ * @param out_request_optimal_range_size Output parameter for calculated request-level optimal range size
372+ * @return AWS_OP_SUCCESS on success, AWS_OP_ERR on failure (caller should fall back to client size)
373+ */
374+ AWS_S3_API
375+ int aws_s3_calculate_request_optimal_range_size (
376+ uint64_t client_optimal_range_size ,
377+ uint64_t estimated_object_stored_part_size ,
378+ bool is_express ,
379+ uint64_t * out_request_optimal_range_size );
380+
381+ /**
382+ * Extract the number of parts from an S3 ETag header value.
383+ * S3 multipart upload ETags have the format "<hash>-<number_of_parts>".
384+ * Single-part uploads have ETags without dashes.
385+ *
386+ * @param etag_header_value The ETag header value (may include quotes)
387+ * @param out_num_parts Output parameter for the number of parts (1 for single-part uploads)
388+ * @return AWS_OP_SUCCESS on success, AWS_OP_ERR on failure (invalid ETag format)
389+ */
390+ AWS_S3_API
391+ int aws_s3_extract_parts_from_etag (struct aws_byte_cursor etag_header_value , uint32_t * out_num_parts );
392+
321393AWS_EXTERN_C_END
322394
323395#endif /* AWS_S3_UTIL_H */
0 commit comments