From fbb95e7c2e23690528d61b13a47d749911c90799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=9B=AA=E5=B3=B0?= Date: Sun, 21 Apr 2024 19:58:18 +0800 Subject: [PATCH] fix wrap_open funciton --- easyapi/mirrorUrlApply.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/easyapi/mirrorUrlApply.py b/easyapi/mirrorUrlApply.py index 76b1bd3..a24510d 100644 --- a/easyapi/mirrorUrlApply.py +++ b/easyapi/mirrorUrlApply.py @@ -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()