Skip to content

Commit 81c3dc9

Browse files
fix: add http user-agent
1 parent 484dfd2 commit 81c3dc9

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/apk/index.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ pub fn parse_index_tar_gz(path: &str) -> Result<Vec<Package>> {
6262
pub fn fetch_remote_index(repo_url: &str, arch: &str) -> Result<Vec<Package>> {
6363
let url = format!("{}/{}/APKINDEX.tar.gz", repo_url.trim_end_matches('/'), arch);
6464

65-
let resp = ureq::get(&url).call().map_err(|e| anyhow!("HTTP request failed: {e}"))?;
65+
let resp = ureq::get(&url)
66+
.set("User-Agent", &format!("vellum-cli/{}", env!("VELLUM_VERSION")))
67+
.call()
68+
.map_err(|e| anyhow!("HTTP request failed: {e}"))?;
6669

6770
if resp.status() != 200 {
6871
return Err(anyhow!("HTTP {}", resp.status()));

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ struct AppState {
3131
}
3232

3333
fn main() {
34+
unsafe { env::set_var("HTTP_USER_AGENT", format!("vellum-cli/{VERSION}")); }
35+
3436
let state = State::new(VELLUM_ROOT);
3537
let apk = Apk::new(VELLUM_ROOT);
3638

0 commit comments

Comments
 (0)