[Misc] Normalize --host parameter to use plain hostname without scheme (#19309)

Co-authored-by: 墨楼 <huangzhilin.hzl@antgroup.com>
Co-authored-by: Liangsheng Yin <lsyincs@gmail.com>
Co-authored-by: Liangsheng Yin <hnyls2002@gmail.com>
This commit is contained in:
Julian Huang
2026-02-25 16:37:24 +08:00
committed by GitHub
parent f75abb4521
commit a55f658835
8 changed files with 52 additions and 25 deletions

View File

@@ -12,6 +12,7 @@ import sys
import time
import traceback
import urllib.request
import warnings
import weakref
from collections import OrderedDict
from concurrent.futures import ThreadPoolExecutor
@@ -122,6 +123,19 @@ def dump_state_text(filename: str, states: list, mode: str = "w"):
)
def normalize_base_url(host: str, port: int) -> str:
if host.startswith("http://") or host.startswith("https://"):
warnings.warn(
f"Including the scheme in --host ('{host}') is deprecated. "
f"Pass just the hostname (e.g. '127.0.0.1') instead.",
DeprecationWarning,
stacklevel=2,
)
else:
host = f"http://{host}"
return f"{host}:{port}"
class HttpResponse:
def __init__(self, resp):
self.resp = resp