post/
post.rs

1use http_req::request;
2
3fn main() {
4    // Container for body of a response.
5    let mut res_body = Vec::new();
6
7    // Body of a request.
8    const REQ_BODY: &[u8; 27] = b"field1=value1&field2=value2";
9
10    // Sends a HTTP POST request and processes the response.
11    let res = request::post("https://httpbin.org/post", REQ_BODY, &mut res_body).unwrap();
12
13    // Prints details about the response.
14    println!("Status: {} {}", res.status_code(), res.reason());
15    println!("Headers: {}", res.headers());
16    //println!("{}", String::from_utf8_lossy(&res_body));
17}