aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-27 09:38:16 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-27 09:38:16 -0600
commit434d285b36cce9d29fd6a8b997469c7a929b96bc (patch)
treed23cd9aacb095842104e44d8b4757bb30c39360b /src
parent79698f03acc59e7c1131dd9a57f0c17d17b33b1a (diff)
downloadwebget-434d285b36cce9d29fd6a8b997469c7a929b96bc.tar.gz
webget-434d285b36cce9d29fd6a8b997469c7a929b96bc.zip
correctly handle HTTPS
Diffstat (limited to 'src')
-rw-r--r--src/download.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/download.rs b/src/download.rs
index 9e126dd..7cf9694 100644
--- a/src/download.rs
+++ b/src/download.rs
@@ -4,13 +4,16 @@ use anyhow::{Error, Context};
use fehler::throws;
use hyper::Uri;
use hyper::body::HttpBody;
-use hyper::client::Client;
+use hyper::client::{Client, HttpConnector};
use hyper::header::{CONTENT_TYPE, LOCATION};
+use hyper_rustls::HttpsConnector;
use tokio::fs;
use tokio::io::AsyncWriteExt;
use super::Args;
+type HttpsClient = Client<HttpsConnector<HttpConnector>>;
+
#[throws]
pub(crate) async fn download(url: Uri, args: &Args) {
let output_file_path = if let Some(output) = &args.output_document {
@@ -23,7 +26,7 @@ pub(crate) async fn download(url: Uri, args: &Args) {
}
};
- let client = Client::new();
+ let client: HttpsClient = Client::builder().build(HttpsConnector::with_native_roots());
let mut response = client.get(url.clone()).await?;
while response.status().is_redirection() {
let location = response.headers()