Эх сурвалжийг харах

[fix] verify setup common header

chemf 6 жил өмнө
parent
commit
9db00588d7
1 өөрчлөгдсөн 5 нэмэгдсэн , 1 устгасан
  1. 5 1
      Util/utilFunction.py

+ 5 - 1
Util/utilFunction.py

@@ -86,8 +86,12 @@ def validUsefulProxy(proxy):
     if isinstance(proxy, bytes):
         proxy = proxy.decode("utf8")
     proxies = {"http": "http://{proxy}".format(proxy=proxy)}
+    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0',
+               'Accept': '*/*',
+               'Connection': 'keep-alive',
+               'Accept-Language': 'zh-CN,zh;q=0.8'}
     try:
-        r = requests.get(config.verify_host, proxies=proxies, timeout=10, verify=False)
+        r = requests.head(config.verify_host, headers=headers, proxies=proxies, timeout=10, verify=False)
         if r.status_code == 200:
             return True
     except Exception as e: