diff options
author | Christophe Priouzeau <christophe.priouzeau@st.com> | 2021-01-20 11:13:06 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-01-23 17:09:26 +0000 |
commit | 9f123238261a68e37cec634782e9320633cac5d4 (patch) | |
tree | 4ce53d3485e9d04d26b9b0b211100c6e5d1d5741 | |
parent | db87aab8e219d2520dcd8d15da89110aadf3d41e (diff) | |
download | poky-9f123238261a68e37cec634782e9320633cac5d4.tar.gz |
bitbake: fetch2/wget: Update user-agent
With the usage of enterprise proxy, the user-agent defined are
too old and refused by proxy configuration. Updating to something
more modern is desirable.
(Bitbake rev: 7001fdd7c4dca372cbebd8fd2c0b03c5d43f9400)
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index e6d9f528d0..e952f411c7 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -52,6 +52,12 @@ class WgetProgressHandler(bb.progress.LineFilterProgressHandler): | |||
52 | 52 | ||
53 | 53 | ||
54 | class Wget(FetchMethod): | 54 | class Wget(FetchMethod): |
55 | |||
56 | # CDNs like CloudFlare may do a 'browser integrity test' which can fail | ||
57 | # with the standard wget/urllib User-Agent, so pretend to be a modern | ||
58 | # browser. | ||
59 | user_agent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0" | ||
60 | |||
55 | """Class to fetch urls via 'wget'""" | 61 | """Class to fetch urls via 'wget'""" |
56 | def supports(self, ud, d): | 62 | def supports(self, ud, d): |
57 | """ | 63 | """ |
@@ -297,7 +303,7 @@ class Wget(FetchMethod): | |||
297 | # Some servers (FusionForge, as used on Alioth) require that the | 303 | # Some servers (FusionForge, as used on Alioth) require that the |
298 | # optional Accept header is set. | 304 | # optional Accept header is set. |
299 | r.add_header("Accept", "*/*") | 305 | r.add_header("Accept", "*/*") |
300 | r.add_header("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12") | 306 | r.add_header("User-Agent", self.user_agent) |
301 | def add_basic_auth(login_str, request): | 307 | def add_basic_auth(login_str, request): |
302 | '''Adds Basic auth to http request, pass in login:password as string''' | 308 | '''Adds Basic auth to http request, pass in login:password as string''' |
303 | import base64 | 309 | import base64 |
@@ -401,9 +407,8 @@ class Wget(FetchMethod): | |||
401 | """ | 407 | """ |
402 | f = tempfile.NamedTemporaryFile() | 408 | f = tempfile.NamedTemporaryFile() |
403 | with tempfile.TemporaryDirectory(prefix="wget-index-") as workdir, tempfile.NamedTemporaryFile(dir=workdir, prefix="wget-listing-") as f: | 409 | with tempfile.TemporaryDirectory(prefix="wget-index-") as workdir, tempfile.NamedTemporaryFile(dir=workdir, prefix="wget-listing-") as f: |
404 | agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/9.10 (karmic) Firefox/3.6.12" | ||
405 | fetchcmd = self.basecmd | 410 | fetchcmd = self.basecmd |
406 | fetchcmd += " -O " + f.name + " --user-agent='" + agent + "' '" + uri + "'" | 411 | fetchcmd += " -O " + f.name + " --user-agent='" + self.user_agent + "' '" + uri + "'" |
407 | try: | 412 | try: |
408 | self._runwget(ud, d, fetchcmd, True, workdir=workdir) | 413 | self._runwget(ud, d, fetchcmd, True, workdir=workdir) |
409 | fetchresult = f.read() | 414 | fetchresult = f.read() |