Rust
Rust
Inspect HTTP Request Header
Demonstrates theLastHeader property.
Chilkat Rust Downloads
let http = chilkat::Http::new();
let url = "https://chilkatsoft.com/echo_request_body.asp".to_string();
let json = "{\"greeting\":\"Hello World\"}".to_string();
// Send a POST with the JSON in the HTTP request body.
let resp = chilkat::HttpResponse::new();
if http.http_str("POST", &url, &json, "utf-8", "application/json", &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
// Examine the HTTP request header we just sent.
println!("{}", http.last_header());
// Output:
// POST /echo_request_body.asp HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
// Content-Type: application/json
// Content-Length: 26