-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44ab978
commit fcedd69
Showing
8 changed files
with
47 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
use http_req::request; | ||
|
||
fn main() { | ||
//Sends a HTTP HEAD request and processes the response. | ||
// Sends a HTTP HEAD request and processes the response. | ||
let res = request::head("https://www.rust-lang.org/learn").unwrap(); | ||
|
||
//Prints details about the response. | ||
// Prints the details about the response. | ||
println!("Status: {} {}", res.status_code(), res.reason()); | ||
println!("Headers: {}", res.headers()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
use http_req::request; | ||
|
||
fn main() { | ||
//Container for body of a response. | ||
// Container for body of a response. | ||
let mut res_body = Vec::new(); | ||
|
||
//Body of a request. | ||
// Body of a request. | ||
const REQ_BODY: &[u8; 27] = b"field1=value1&field2=value2"; | ||
|
||
//Sends a HTTP POST request and processes the response. | ||
// Sends a HTTP POST request and processes the response. | ||
let res = request::post("https://httpbin.org/post", REQ_BODY, &mut res_body).unwrap(); | ||
|
||
//Prints details about the response. | ||
// Prints details about the response. | ||
println!("Status: {} {}", res.status_code(), res.reason()); | ||
println!("Headers: {}", res.headers()); | ||
println!("{}", String::from_utf8_lossy(&res_body)); | ||
//println!("{}", String::from_utf8_lossy(&res_body)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters