-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot download package possibly because of urllib defaults #218
Comments
Workaround: get the FontAwesome package from GitHub instead. https://github.com/FortAwesome/Font-Awesome/releases/download/5.15.4/fontawesome-free-5.15.4-web.zip |
I think this is still worth trying to add some more debugging information to or at least trying to figure out if the dependency on urllib is problematic when retrieving from Cloudflare-backed URLs. |
Interesting, thanks for the detailed report. I've played with it a little bit, and it seems like the key detail is that the User-Agent header has to be set. Here's a minimized repro: from urllib.request import Request, urlopen
url = "https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip"
req = Request(url)
# Even with an empty string as the User-Agent header, the request succeeds. But
# if we remove this line, the request fails with error 403.
req.add_header("user-agent", "")
urlopen(req) @colindean can you confirm this behavior? I guess it's reasonable that Peru should set something for the UA. Any proposals for what that should be? @olson-sean-k? |
Confirmed. I'd suggest this: urllib3 uses
If you look at the source for |
The header will be of the form: peru/{version} Python-urllib/{version} Fixes buildinspace#218
I put up #219 with a stab at a quick fix. It adds the header, at least. I didn't actually test it with my config example above, though, yet. |
I tested #219 with the example config and it works! It will fix the problem. |
Thanks for finding (and fixing) this, @colindean!
I'm not too sure, but I think there are three reasonable options:
FWIW, I think I'd lean a bit toward the first option, but I don't have a strong opinion about it. |
#219 goes with № 3 in that list and pulls the urllib UA directly from a core class that won't go away. urllib doesn't — IMO — sufficiently abstract this value 👎 |
I'm trying to import fontawesome to a project using Peru 1.3.0.
But it errors:
I think it's a urllib problem:
The urllib request fails but urllib3 succeeds. I don't think urllib's HTTPError gives you access to the request headers, so I can't really tell what's wrong here. I'm able to retrieve the file with curl, wget, aria2c, and python via urllib3.
Running
peru --verbose sync
gave me a stack trace that simply emphasizes "yeah, that's a 403" and the headers I get back from the request don't really say what's wrong. I assume it's some kind of bot protection on Cloudflare…?The text was updated successfully, but these errors were encountered: