fix
This commit is contained in:
1675
my-blog/content/posts/2025-08-09-9935c5b5.md
Normal file
1675
my-blog/content/posts/2025-08-09-9935c5b5.md
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -45,7 +45,10 @@ pub struct ProfileFetcher {
|
|||||||
impl ProfileFetcher {
|
impl ProfileFetcher {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
client: reqwest::Client::new(),
|
client: reqwest::Client::builder()
|
||||||
|
.timeout(std::time::Duration::from_secs(30))
|
||||||
|
.build()
|
||||||
|
.unwrap_or_else(|_| reqwest::Client::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,11 +87,14 @@ impl ProfileFetcher {
|
|||||||
let response = self.client
|
let response = self.client
|
||||||
.get(&url)
|
.get(&url)
|
||||||
.query(&[("repo", handle)])
|
.query(&[("repo", handle)])
|
||||||
|
.timeout(std::time::Duration::from_secs(10))
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await
|
||||||
|
.map_err(|e| anyhow::anyhow!("Request failed: {}", e))?;
|
||||||
|
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
return Err(anyhow::anyhow!("Failed to describe repo: {}", response.status()));
|
let error_text = response.text().await.unwrap_or_default();
|
||||||
|
return Err(anyhow::anyhow!("Failed to describe repo: {} - {}", response.status(), error_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
let repo_desc: RepoDescription = response.json().await?;
|
let repo_desc: RepoDescription = response.json().await?;
|
||||||
@@ -117,11 +123,14 @@ impl ProfileFetcher {
|
|||||||
let response = self.client
|
let response = self.client
|
||||||
.get(&url)
|
.get(&url)
|
||||||
.query(&[("actor", did)])
|
.query(&[("actor", did)])
|
||||||
|
.timeout(std::time::Duration::from_secs(10))
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await
|
||||||
|
.map_err(|e| anyhow::anyhow!("Request failed: {}", e))?;
|
||||||
|
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
return Err(anyhow::anyhow!("Failed to get profile: {}", response.status()));
|
let error_text = response.text().await.unwrap_or_default();
|
||||||
|
return Err(anyhow::anyhow!("Failed to get profile: {} - {}", response.status(), error_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
let profile_data: Value = response.json().await?;
|
let profile_data: Value = response.json().await?;
|
||||||
|
Reference in New Issue
Block a user