Pārlūkot izejas kodu

Specify user-agent header when downloading Python builds

This should allow Python devs to see how many people are using Pynsist.
Thomas Kluyver 9 gadi atpakaļ
vecāks
revīzija
83c76f0a01
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. 4 1
      nsist/util.py

+ 4 - 1
nsist/util.py

@@ -20,7 +20,10 @@ def download(url, target):
     """
     if isinstance(target, Path):
         target = str(target)
-    r = requests.get(url, stream=True)
+
+    from . import __version__
+    headers = {'user-agent': 'Pynsist/'+__version__}
+    r = requests.get(url, headers=headers, stream=True)
     r.raise_for_status()
     with open(target, 'wb') as f:
         for chunk in r.iter_content(chunk_size=1024):