Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.

Commit 0e84060

Browse files
committed
Add user agent to pypi requests
1 parent cdc0eec commit 0e84060

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sources/pypi.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,13 @@ fn fetch_download_url_for_package(
171171
version: &String,
172172
changelogs: Vec<ChangelogItem>,
173173
) -> Result<Vec<PackageToProcess>> {
174+
let client = reqwest::blocking::Client::new();
174175
let url = format!("https://pypi.org/pypi/{name}/{version}/json");
175-
let response =
176-
reqwest::blocking::get(&url).with_context(|| format!("Failed to request URL {}", url))?;
176+
let response = client
177+
.get(&url)
178+
.header("User-Agent", "https://github.com/orf/aws-creds-scanner")
179+
.send()
180+
.with_context(|| format!("Failed to request URL {}", url))?;
177181
// Some versions are not valid URLs. For example, `weightless-core @ 0.5.2.3-seecr-%`
178182
// These result in 400's, in which case we just return [].
179183
if response.status() == 404 || response.status() == 400 {

0 commit comments

Comments
 (0)