Fetches content from a URL and writes it to the cache
(client: &Client, url: &str, cache_path: &PathBuf)
| 80 | |
| 81 | /// Fetches content from a URL and writes it to the cache |
| 82 | async fn fetch_and_cache(client: &Client, url: &str, cache_path: &PathBuf) -> Result<String> { |
| 83 | let res = client.get(url).send().await?; |
| 84 | if !res.status().is_success() { |
| 85 | anyhow::bail!("HTTP {} for {}", res.status(), url); |
| 86 | } |
| 87 | let contents = res.text().await?; |
| 88 | write(cache_path, &contents)?; |
| 89 | Ok(contents) |
| 90 | } |
| 91 | |
| 92 | /// Fetches web features data from the web-features repository |
| 93 | pub async fn get_web_features_data(client: &Client) -> Result<WebFeaturesData> { |