diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2020-06-25 11:28:39 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-06-26 16:07:29 -0400 |
commit | 33167d40a29fea6b2b09fe0bc8a9eff5904857de (patch) | |
tree | 97c049e59beb49cf1c024307569819b8ee4fd871 /mesonbuild/wrap/wrap.py | |
parent | 6aabc205f71c44475d364b10f4bcca5fcaf38a7e (diff) | |
download | meson-33167d40a29fea6b2b09fe0bc8a9eff5904857de.zip meson-33167d40a29fea6b2b09fe0bc8a9eff5904857de.tar.gz meson-33167d40a29fea6b2b09fe0bc8a9eff5904857de.tar.bz2 |
wrap: add user agent when downloading files
This lets servers know when they're being used by meson. It also avoids
issues where the Independent JPEG Group decided to ban the
"Python-urllib" default user agent.
Fixes https://github.com/mesonbuild/libjpeg/issues/9
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r-- | mesonbuild/wrap/wrap.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 44173f7..5afbe8f 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -29,6 +29,7 @@ import typing as T from pathlib import Path from . import WrapMode +from .. import coredata from ..mesonlib import git, GIT, ProgressBar, MesonException if T.TYPE_CHECKING: @@ -329,7 +330,8 @@ class Resolver: raise WrapException('{} may be a WrapDB-impersonating URL'.format(urlstring)) else: try: - resp = urllib.request.urlopen(urlstring, timeout=REQ_TIMEOUT) + req = urllib.request.Request(urlstring, headers={'User-Agent': 'mesonbuild/{}'.format(coredata.version)}) + resp = urllib.request.urlopen(req, timeout=REQ_TIMEOUT) except urllib.error.URLError as e: mlog.log(str(e)) raise WrapException('could not get {} is the internet available?'.format(urlstring)) |