diff options
author | Paul Barker <pbarker@konsulko.com> | 2020-04-16 09:49:05 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-04-24 14:31:42 +0100 |
commit | ab26fdae9e5ae56bb84196698d3fa4fd568fe903 (patch) | |
tree | 3ae877fae3fd04d7da86ce86696eb9f7906f397a | |
parent | 03826c61fdb9949d6812c586e5407249fbb9bee9 (diff) | |
download | poky-ab26fdae9e5ae56bb84196698d3fa4fd568fe903.tar.gz |
bitbake: fetch2/wget: Set User-Agent when checking status of a URL
When a website is behind a CDN like Cloudflare there may be a "Browser
Integrity Check" or other test applied to requests before they are
allowed through to the server. Downloading via wget passes these tests
as headers are set appropriately, however the Python urllib module may
fail these tests unless additional headers are set. This causes
Wget.checkstatus() to fail where Wget.download() would actually succeed.
For Cloudflare in particular a valid User-Agent is needed, it's easy to
add this to the headers in Wget.checkstatus(). The user agent string is
copied from Wget._fetch_index().
(Bitbake rev: 4679d3cdb9cdf23f3962aa61c599ad7474591f9f)
Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index 5235ae4d9e..f7d1de26b7 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -300,6 +300,7 @@ class Wget(FetchMethod): | |||
300 | # Some servers (FusionForge, as used on Alioth) require that the | 300 | # Some servers (FusionForge, as used on Alioth) require that the |
301 | # optional Accept header is set. | 301 | # optional Accept header is set. |
302 | r.add_header("Accept", "*/*") | 302 | r.add_header("Accept", "*/*") |
303 | 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") | ||
303 | def add_basic_auth(login_str, request): | 304 | def add_basic_auth(login_str, request): |
304 | '''Adds Basic auth to http request, pass in login:password as string''' | 305 | '''Adds Basic auth to http request, pass in login:password as string''' |
305 | import base64 | 306 | import base64 |