fix wrap_open funciton

This commit is contained in:
刘雪峰
2024-04-21 19:58:18 +08:00
parent 3ce4b6dbb4
commit fbb95e7c2e
+4 -2
View File
@@ -113,12 +113,14 @@ def replace_mirror_url():
found, u, user_agent = replace_url(fullurl)
if found:
url = u.geturl()
data = None
if user_agent is not None:
headers = {'User-Agent': user_agent}
url = urllib.request.Request(url, data=data, headers=headers)
return origin_urllib_open.__call__(obj, url, data, timeout)
return origin_urllib_open.__call__(obj, url, data, timeout)
else:
return origin_urllib_open.__call__(obj, fullurl, data, timeout)
else:
# url is urllib.request.Request
full_url = fullurl.get_full_url()