Sample code for 30+ languages & platforms
Rust

Example: Http.ResumeDownloadBd method

Demonstrates the ResumeDownloadBd method.

Chilkat Rust Downloads

Rust
let mut success = false;

let http = chilkat::Http::new();
http.set_keep_response_body(true);

// To demonstrate resuming a download, we've created a file on the chilkatsoft.com
// web server that contains the first 82,379 bytes of the full  279,658 bytes of the hamlet.xml file.

// We'll first download the partial file, and pretend it was a previous incomplete attempt to download the entire file.
let bd = chilkat::BinData::new();
success = http.download_bd("https://www.chilkatsoft.com/testData/hamlet_partial.xml", &bd).is_ok();
if !success {
    println!("{}", http.last_error_text());
    return;
}

// Download the remainder of hamlet.xml.
success = http.resume_download_bd("https://www.chilkatsoft.com/testData/hamlet.xml", &bd).is_ok();
let status_code = http.last_status();
if !success {
    if status_code == 0 {
        // Unable to either send the request or get the response.
        println!("{}", http.last_error_text());
    } else {
        // We got a response, but the status code was not in the 200s
        println!("Response status code: {}", status_code);
        // Examine the response body.
        println!("Response body:");
        println!("{}", http.last_response_body());
    }

    println!("Download failed.");

} else {
    println!("Download success, response status = {}", status_code);
}

// The hamlet.xml file should be 279,658 bytes
println!("size of hamlet.xml: {}", bd.num_bytes());

println!("Success.");