diff --git a/PILOTVERSION b/PILOTVERSION index 51c9881a..2fb403f4 100644 --- a/PILOTVERSION +++ b/PILOTVERSION @@ -1 +1 @@ -3.9.2.22 \ No newline at end of file +3.9.2.23b \ No newline at end of file diff --git a/pilot/util/constants.py b/pilot/util/constants.py index 6b9bd5c3..1334b93b 100644 --- a/pilot/util/constants.py +++ b/pilot/util/constants.py @@ -28,7 +28,7 @@ RELEASE = '3' # released number should be fixed at 3 for Pilot 3 VERSION = '9' # version number is '1' for first release, '0' until then, increased for bigger updates REVISION = '2' # revision number should be reset to '0' for every new version release, increased for small updates -BUILD = '22' # build number should be reset to '1' for every new development cycle +BUILD = '23' # build number should be reset to '1' for every new development cycle SUCCESS = 0 FAILURE = 1 diff --git a/pilot/util/https.py b/pilot/util/https.py index 1f5bef31..9b483e9a 100644 --- a/pilot/util/https.py +++ b/pilot/util/https.py @@ -859,8 +859,7 @@ def request2(url: str = "", if ipv == 'IPv4': logger.info("will use IPv4 in server communication") - opener = urllib.request.build_opener(IPv4HTTPHandler()) - urllib.request.install_opener(opener) + install_ipv4_opener() else: logger.info("will use IPv6 in server communication") @@ -870,10 +869,10 @@ def request2(url: str = "", logger.debug('sending data to server') with urllib.request.urlopen(req, context=ssl_context, timeout=config.Pilot.http_maxtime) as response: # Handle the response here - logger.debug(f"response.status={response.status}, response.reason={response.reason}") + logger.info(f"response.status={response.status}, response.reason={response.reason}") ret = response.read().decode('utf-8') if 'getProxy' not in url: - logger.debug(f"response={ret}") + logger.info(f"response={ret}") logger.debug('sent request to server') except (urllib.error.URLError, urllib.error.HTTPError, TimeoutError) as exc: logger.warning(f'failed to send request: {exc}') @@ -897,6 +896,24 @@ def request2(url: str = "", return ret +def install_ipv4_opener(): + """Install the IPv4 opener.""" + http_proxy = os.environ.get("http_proxy") + all_proxy = os.environ.get("all_proxy") + if http_proxy and all_proxy: + logger.info(f"using http_proxy={http_proxy}, all_proxy={all_proxy}") + proxy_handler = urllib.request.ProxyHandler({ + 'http': http_proxy, + 'https': http_proxy, + 'all': all_proxy + }) + opener = urllib.request.build_opener(proxy_handler, IPv4HTTPHandler()) + else: + logger.info("no http_proxy found, will use IPv4 without proxy") + opener = urllib.request.build_opener(IPv4HTTPHandler()) + urllib.request.install_opener(opener) + + def request2_old(url: str = "", data: dict = None, secure: bool = True,