Add user agent header for fetch latest commit
For some reason GitLab (or CloudFlare) respond with 403 Forbidden for requests made using urllib. By setting the user agent we can complete the requests successfully. See https://gitlab.com/gitlab-org/gitlab/-/issues/219669 for the corresponding issue in the GitLab issue tracker.
This commit is contained in:
parent
1444f0ba22
commit
e0128b42cf
1 changed files with 3 additions and 2 deletions
|
|
@ -13,9 +13,10 @@ from .manifest import LockedVersion, Repo, RepoType
|
|||
|
||||
|
||||
def fetch_commit_from_feed(url: str) -> str:
|
||||
req = urllib.request.urlopen(url)
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "nur-updater"})
|
||||
res = urllib.request.urlopen(req)
|
||||
try:
|
||||
xml = req.read()
|
||||
xml = res.read()
|
||||
root = ET.fromstring(xml)
|
||||
ns = "{http://www.w3.org/2005/Atom}"
|
||||
xpath = f"./{ns}entry/{ns}link"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue