pub async fn add_checksum_treehash(request: &mut Request) -> Result<(), byte_stream::Error> {
    let cloneable = request.http().body().try_clone();
    let http_request = request.http_mut();
    let body_to_process = if let Some(cloned_body) = cloneable {
        // we can stream the body
        cloned_body
    } else {
        let body = std::mem::replace(http_request.body_mut(), SdkBody::taken());
        let loaded_body = ByteStream::new(body).collect().await?.into_bytes();
        *http_request.body_mut() = SdkBody::from(loaded_body.clone());
        SdkBody::from(loaded_body)
    };
    let (full_body, hashes) = compute_hashes(body_to_process, MEGABYTE).await?;
    let tree_hash = hex::encode(compute_hash_tree(hashes));
    let complete_hash = hex::encode(full_body);
    if !http_request.headers().contains_key(TREE_HASH_HEADER) {
        http_request.headers_mut().insert(
            HeaderName::from_static(TREE_HASH_HEADER),
            tree_hash.parse().expect("hash must be valid header"),
        );
    }
    if !http_request.headers().contains_key(X_AMZ_CONTENT_SHA256) {
        http_request.headers_mut().insert(
            HeaderName::from_static(X_AMZ_CONTENT_SHA256),
            complete_hash.parse().expect("hash must be valid header"),
        );
    }
    // if we end up hitting the signer later, no need to recompute the checksum
    request
        .properties_mut()
        .insert(SignableBody::Precomputed(complete_hash));
    // for convenience & protocol tests, write it in directly here as well
    Ok(())
}
/// Adds a glacier tree hash checksum to the HTTP Request
///
/// This handles two cases:
/// 1. A body which is retryable: the body will be streamed through a digest calculator, limiting memory usage.
/// 2. A body which is not retryable: the body will be converted into `Bytes`, then streamed through a digest calculator.
///
/// The actual checksum algorithm will first compute a SHA256 checksum for each 1MB chunk. Then, a tree
/// will be assembled, recursively pairing neighboring chunks and computing their combined checksum. The 1 leftover
/// chunk (if it exists) is paired at the end.
///
/// See <https://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html> for more information.
Adds a glacier tree hash checksum to the HTTP Request
This handles two cases:
1. A body which is retryable: the body will be streamed through a digest calculator, limiting memory usage.
2. A body which is not retryable: the body will be converted into `Bytes`, then streamed through a digest calculator.

The actual checksum algorithm will first compute a SHA256 checksum for each 1MB chunk. Then, a tree
will be assembled, recursively pairing neighboring chunks and computing their combined checksum. The 1 leftover
chunk (if it exists) is paired at the end.

See  for more information.
Adds a glacier tree hash checksum to the HTTP Request This handles two cases : 1 . A body which is retryable : the body will be streamed through a digest calculator limiting memory usage . 2 . A body which is not retryable : the body will be converted into ` Bytes ` then streamed through a digest calculator . The actual checksum algorithm will first compute a SHA256 checksum for each 1MB chunk . Then a tree will be assembled recursively pairing neighboring chunks and computing their combined checksum . The 1 leftover chunk ( if it exists ) is paired at the end . See for more information .
pub async fn add_checksum_treehash(request: &mut Request) -> Result<(), byte_stream::Error> {
    let cloneable = request.http().body().try_clone();
    let http_request = request.http_mut();
    let body_to_process = if let Some(cloned_body) = cloneable {
        // we can stream the body
        cloned_body
    } else {
        let body = std::mem::replace(http_request.body_mut(), SdkBody::taken());
        let loaded_body = ByteStream::new(body).collect().await?.into_bytes();
        *http_request.body_mut() = SdkBody::from(loaded_body.clone());
        SdkBody::from(loaded_body)
    };
    let (full_body, hashes) = compute_hashes(body_to_process, MEGABYTE).await?;
    let tree_hash = hex::encode(compute_hash_tree(hashes));
    let complete_hash = hex::encode(full_body);
    if !http_request.headers().contains_key(TREE_HASH_HEADER) {
        http_request.headers_mut().insert(
            HeaderName::from_static(TREE_HASH_HEADER),
            tree_hash.parse().expect("hash must be valid header"),
        );
    }
    if !http_request.headers().contains_key(X_AMZ_CONTENT_SHA256) {
        http_request.headers_mut().insert(
            HeaderName::from_static(X_AMZ_CONTENT_SHA256),
            complete_hash.parse().expect("hash must be valid header"),
        );
    }
    // if we end up hitting the signer later, no need to recompute the checksum
    request
        .properties_mut()
        .insert(SignableBody::Precomputed(complete_hash));
    // for convenience & protocol tests, write it in directly here as well
    Ok(())
}
pub async fn add_checksum_treehash ( request : & mut Request ) -> Result < ( ) , byte_stream :: Error > { let cloneable = request . http ( ) . body ( ) . try_clone ( ) ; let http_request = request . http_mut ( ) ; let body_to_process = if let Some ( cloned_body ) = cloneable { // we can stream the body cloned_body } else { let body = std :: mem :: replace ( http_request . body_mut ( ) , SdkBody :: taken ( ) ) ; let loaded_body = ByteStream :: new ( body ) . collect ( ) . await ? . into_bytes ( ) ; * http_request . body_mut ( ) = SdkBody :: from ( loaded_body . clone ( ) ) ; SdkBody :: from ( loaded_body ) } ; let ( full_body , hashes ) = compute_hashes ( body_to_process , MEGABYTE ) . await ? ; let tree_hash = hex :: encode ( compute_hash_tree ( hashes ) ) ; let complete_hash = hex :: encode ( full_body ) ; if ! http_request . headers ( ) . contains_key ( TREE_HASH_HEADER ) { http_request . headers_mut ( ) . insert ( HeaderName :: from_static ( TREE_HASH_HEADER ) , tree_hash . parse ( ) . expect ( " " ) , ) ; } if ! http_request . headers ( ) . contains_key ( X_AMZ_CONTENT_SHA256 ) { http_request . headers_mut ( ) . insert ( HeaderName :: from_static ( X_AMZ_CONTENT_SHA256 ) , complete_hash . parse ( ) . expect ( " " ) , ) ; } // if we end up hitting the signer later, no need to recompute the checksum request . properties_mut ( ) . insert ( SignableBody :: Precomputed ( complete_hash ) ) ; // for convenience & protocol tests, write it in directly here as well Ok ( ( ) ) }
Adds a glacier tree hash checksum to the HTTP Request
This handles two cases:
1.
Adds a glacier tree hash checksum to the HTTP Request This handles two cases : 1 .
request
&mut Request
request
&mut Request