Sample code for 30+ languages & platforms
Rust

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat Rust Downloads

Rust
let mut success = false;

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

let sb = chilkat::StringBuilder::new();
success = http.download_sb("https://chilkatsoft.com/testData/helloWorld.txt", "utf-8", &sb).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);
    println!("{}", sb.get_as_string().unwrap_or_default());
}