diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-11-19 12:49:08 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-11-19 12:49:08 +0100 |
| commit | fa43b4bf5d267f7e8cf0dc84ada2749ff3e1b6ca (patch) | |
| tree | 0ca740ada3db3f56449485904869f64a1eca9eca /crates/typst-cli/src/download.rs | |
| parent | e0d6526a53db562fb26d3fcfba091412d3c93bf4 (diff) | |
Use proxy for fetching release metadata
Diffstat (limited to 'crates/typst-cli/src/download.rs')
| -rw-r--r-- | crates/typst-cli/src/download.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/typst-cli/src/download.rs b/crates/typst-cli/src/download.rs index 9db73fe8..e5a97cda 100644 --- a/crates/typst-cli/src/download.rs +++ b/crates/typst-cli/src/download.rs @@ -37,6 +37,13 @@ static TLS_CONFIG: Lazy<Option<Arc<rustls::ClientConfig>>> = Lazy::new(|| { /// Download binary data and display its progress. #[allow(clippy::result_large_err)] pub fn download_with_progress(url: &str) -> Result<Vec<u8>, ureq::Error> { + let response = download(url)?; + Ok(RemoteReader::from_response(response).download()?) +} + +/// Download from a URL. +#[allow(clippy::result_large_err)] +pub fn download(url: &str) -> Result<ureq::Response, ureq::Error> { let mut builder = ureq::AgentBuilder::new() .user_agent(concat!("typst/{}", env!("CARGO_PKG_VERSION"))); @@ -54,8 +61,7 @@ pub fn download_with_progress(url: &str) -> Result<Vec<u8>, ureq::Error> { } let agent = builder.build(); - let response = agent.get(url).call()?; - Ok(RemoteReader::from_response(response).download()?) + agent.get(url).call() } /// A wrapper around [`ureq::Response`] that reads the response body in chunks |
