[gimp-web] tools: add again HTTP header to the check mirror script.



commit 1f961e52f8d23320b0a99124deb97fe21aaf25d5
Author: Jehan <jehan girinstud io>
Date:   Fri Jun 3 19:24:09 2022 +0200

    tools: add again HTTP header to the check mirror script.
    
    Basically redoing commit 7f4eeecf as the improvement got dropped
    unexpectedly when I moved to the requests module.
    And now the same mirror (jaleco) was returning test requests with 403
    errors.

 tools/downloads/gimp-check-mirrors.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/tools/downloads/gimp-check-mirrors.py b/tools/downloads/gimp-check-mirrors.py
index 1d5964c8..5908efc4 100755
--- a/tools/downloads/gimp-check-mirrors.py
+++ b/tools/downloads/gimp-check-mirrors.py
@@ -97,9 +97,10 @@ def verify_remote(uri, future):
   success     = False
   status      = None
   checksum_ok = None
+  headers = {'User-Agent': 'Mozilla/5.0'}
   try:
     if future is not None:
-      with requests.get(uri, stream=True) as response:
+      with requests.get(uri, stream=True, headers=headers) as response:
         m = hashlib.sha256()
         # I don't think the chunk_size is useful, since docs
         # says that "stream=True will read data as it arrives
@@ -115,7 +116,7 @@ def verify_remote(uri, future):
           checksum_ok = False
         status = str(response.status_code)
     else:
-      response = requests.head(url=uri, timeout=20, allow_redirects=True)
+      response = requests.head(url=uri, timeout=20, allow_redirects=True, headers=headers)
       status = str(response.status_code)
       if response.status_code == 200:
         success = True


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]