Skip to content

Commit

Permalink
make sure all async get uses custom fetch func
Browse files Browse the repository at this point in the history
  • Loading branch information
digizeph committed Aug 22, 2024
1 parent 50d2220 commit 1dc3505
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ required-features = ["cli"]
#############################################
chrono = { version = "0.4", features = ["serde"] }
log = "0.4"
reqwest = { version = "0.11.17", default-features = false, features = ["blocking", "json", "stream", "rustls-tls-native-roots"] }
reqwest = { version = "0.12.7", default-features = false, features = ["blocking", "json", "stream", "rustls-tls-native-roots"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/cli/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::io::Write;
use std::time::Duration;

pub async fn download_file(url: &str, path: &str, silent: bool) -> Result<(), String> {
let client = reqwest::Client::builder()
let client = reqwest::ClientBuilder::new()
.user_agent("bgpkit-broker/3")
.timeout(Duration::from_secs(30))
.build()
Expand Down
4 changes: 2 additions & 2 deletions src/crawler/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn extract_link_size(body: &str) -> Vec<(String, i64)> {
}

pub(crate) async fn fetch_body(url: &str) -> Result<String, BrokerError> {
let client = reqwest::Client::builder()
let client = reqwest::ClientBuilder::new()
.user_agent("bgpkit-broker/3")
.pool_max_idle_per_host(0)
.timeout(Duration::from_secs(30))
Expand Down Expand Up @@ -117,7 +117,7 @@ pub(crate) async fn crawl_months_list(
from_month.map(|d| NaiveDate::from_ymd_opt(d.year(), d.month(), 1).unwrap());

let month_link_pattern: Regex = Regex::new(r#"<a href="(....\...)/">.*"#).unwrap();
let body = reqwest::get(collector_root_url).await?.text().await?;
let body = fetch_body(collector_root_url).await?;
let mut res = vec![];
for cap in month_link_pattern.captures_iter(body.as_str()) {
let month = cap[1].to_owned();
Expand Down

0 comments on commit 1dc3505

Please sign in to comment.