Skip to content

Commit e3b4256

Browse files
committedFeb 17, 2025·
Update ureq to the latest version
This fixes #826. Changelog: changed
1 parent ef65eaa commit e3b4256

File tree

4 files changed

+126
-388
lines changed

4 files changed

+126
-388
lines changed
 

‎Cargo.lock

+112-369
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inko/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rust-version.workspace = true
1010
getopts = "^0.2"
1111
compiler = { path = "../compiler" }
1212
types = { path = "../types" }
13-
ureq = { version = "^2.9", default-features = false, features = ["tls"] }
13+
ureq = { version = "^3.0" }
1414
flate2 = "^1.0"
1515
tar = { version = "^0.4", default-features = false }
1616
blake3 = "^1.5"

‎inko/src/command/runtime/add.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,18 @@ fn download(target: &Target) -> Result<PathBuf, Error> {
7171
archive_name,
7272
);
7373

74-
let response = http::get(&url)?;
74+
let mut response = http::get(&url)?;
7575
let total = response
76-
.header("Content-Length")
76+
.headers()
77+
.get("Content-Length")
78+
.and_then(|v| v.to_str().ok())
7779
.and_then(|v| v.parse::<usize>().ok())
7880
.unwrap_or(0);
7981

8082
// We don't decompress here right away as that prevents us from reporting
8183
// progress correctly (due to the total read size being different from the
8284
// Content-Length value).
83-
let mut reader = response.into_reader();
85+
let mut reader = response.body_mut().as_reader();
8486
let path = temp_dir().join(archive_name);
8587
let mut file = File::create(&path).map_err(|e| {
8688
Error::from(format!("failed to open {}: {}", path.display(), e))

‎inko/src/http.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
use crate::error::Error;
22
use std::time::Duration;
3-
use ureq::{self, Agent, Error as HttpError, Response};
3+
use ureq::http::Response;
4+
use ureq::{self, Agent, Body};
45

56
const TIMEOUT: u64 = 10;
67

7-
pub(crate) fn get(url: &str) -> Result<Response, Error> {
8+
pub fn get(url: &str) -> Result<Response<Body>, Error> {
89
let agent = agent();
910

1011
match agent.get(url).call() {
1112
Ok(response) => Ok(response),
12-
Err(HttpError::Status(code, response)) => Err(Error::from(format!(
13-
"GET {} failed: HTTP {} {}",
14-
url,
15-
code,
16-
response.status_text()
17-
))),
18-
Err(HttpError::Transport(err)) => {
19-
Err(Error::from(format!("GET {} failed: {}", url, err)))
20-
}
13+
Err(err) => Err(Error::from(format!("GET {} failed: {}", url, err))),
2114
}
2215
}
2316

2417
fn agent() -> Agent {
25-
ureq::builder()
26-
.timeout_connect(Duration::from_secs(TIMEOUT))
27-
.timeout_read(Duration::from_secs(TIMEOUT))
28-
.user_agent(&format!("inko {}", env!("CARGO_PKG_VERSION")))
18+
Agent::config_builder()
19+
.timeout_global(Some(Duration::from_secs(TIMEOUT)))
20+
.user_agent(format!("inko {}", env!("CARGO_PKG_VERSION")))
2921
.build()
22+
.into()
3023
}

0 commit comments

Comments
 (0)
Please sign in to comment.