Update http-get to reqwest 0.9.

pull/7/head
Jim Blandy 4 years ago
parent 0a5ee8ea66
commit 9b8d21b422

1504
http-get/Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -4,4 +4,4 @@ version = "0.1.0"
authors = ["You <you@example.com>"] authors = ["You <you@example.com>"]
[dependencies] [dependencies]
reqwest = "0.5.1" reqwest = "0.9"

@ -1,9 +1,9 @@
extern crate reqwest; extern crate reqwest;
use std::error::Error; use std::error::Error;
use std::io::{self, Write}; use std::io;
fn http_get_main(url: &str) -> Result<(), Box<Error>> { fn http_get_main(url: &str) -> Result<(), Box<dyn Error>> {
// Send the HTTP request and get a response. // Send the HTTP request and get a response.
let mut response = reqwest::get(url)?; let mut response = reqwest::get(url)?;
if !response.status().is_success() { if !response.status().is_success() {
@ -20,11 +20,11 @@ fn http_get_main(url: &str) -> Result<(), Box<Error>> {
fn main() { fn main() {
let args: Vec<String> = std::env::args().collect(); let args: Vec<String> = std::env::args().collect();
if args.len() != 2 { if args.len() != 2 {
writeln!(io::stderr(), "usage: http-get URL").unwrap(); eprintln!("usage: http-get URL");
return; return;
} }
if let Err(err) = http_get_main(&args[1]) { if let Err(err) = http_get_main(&args[1]) {
writeln!(io::stderr(), "error: {}", err).unwrap(); eprintln!("error: {}", err);
} }
} }

Loading…
Cancel
Save