From 434d285b36cce9d29fd6a8b997469c7a929b96bc Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 27 Mar 2021 09:38:16 -0600 Subject: correctly handle HTTPS --- src/download.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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>; + #[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() -- cgit v1.2.3