Commit c00419a464 for qemu.org

commit c00419a46432f4aaa1e03e3de6a21a4cf775b482
Author: Daniel P. Berrangé <berrange@redhat.com>
Date:   Fri Nov 20 09:41:08 2026 +0000

    tests/functional: add Accept header when downloading assets

    elinux.org is currently triggering an Anubis challenge for requests
    to download assets. After comparing the headers that curl sends, it
    was narrowed down to the omission of an "Accept" header.

    A missing "Accept" header is a rule that Anubis added a year ago
    which is known to hit python's urllib:

      https://github.com/TecharoHQ/anubis/issues/1346

    the bug indicates the rule was removed by default at that time,
    however, rules have evolved further since then and look like they
    are hitting our downloads. Adding the header is simple & harmless.

    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 0abd89e0a3..ffa01aba2f 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -137,7 +137,16 @@ def _try_to_fetch(self, tmp_cache_file):
         for _retries in range(3):
             try:
                 with tmp_cache_file.open("xb") as dst:
-                    with urllib.request.urlopen(self.url) as resp:
+                    req = urllib.request.Request(
+                        self.url,
+                        headers={
+                            # Workaround Anubis challenge which some sites
+                            # trigger when Accept is missing:
+                            #  https://github.com/TecharoHQ/anubis/issues/1346
+                            "Accept": "*/*",
+                        }
+                    )
+                    with urllib.request.urlopen(req) as resp:
                         copyfileobj(resp, dst)
                         length_hdr = resp.getheader("Content-Length")