Skip to content

Commit cbe00af

Browse files
committed
don't use blocking reqwest
1 parent 2053145 commit cbe00af

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

Cargo.lock

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html2rdf-cli/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ html2rdf = { workspace = true }
1919
oxiri = { workspace = true }
2020
oxrdf = { workspace = true }
2121
oxttl = { workspace = true }
22-
reqwest = { version = "0.13.2", default-features = false, features = ["blocking", "charset", "http2", "native-tls", "system-proxy"] }
22+
reqwest = { version = "0.13.2", default-features = false, features = ["charset", "http2", "native-tls", "system-proxy"] }
23+
tokio = { version = "1.49.0", features = ["macros", "rt"] }
2324
url = "2.5.8"

html2rdf-cli/src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ struct Args {
99
target: url::Url,
1010
}
1111

12-
fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
12+
#[tokio::main(flavor = "current_thread")]
13+
async fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
1314
let args = Args::parse();
14-
let client = reqwest::blocking::Client::new();
15+
let client = reqwest::Client::new();
1516
let base = args.target.to_string();
1617
let base_iri = oxiri::Iri::parse(base.clone())?;
17-
let response = client.get(args.target).send()?.error_for_status()?;
18+
let response = client.get(args.target).send().await?.error_for_status()?;
1819
let content_type = response
1920
.headers()
2021
.get(reqwest::header::CONTENT_TYPE)
@@ -25,7 +26,9 @@ fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
2526
return Ok(ExitCode::FAILURE);
2627
}
2728

28-
let content = response.text()?;
29+
drop(client);
30+
31+
let content = response.text().await?;
2932
let mut output_graph = oxrdf::Graph::new();
3033
let mut processor_graph = oxrdf::Graph::new();
3134
html2rdf::process(

0 commit comments

Comments
 (0)