提供 requirements.txt,TitleServer支持配置Http代理
This commit is contained in:
@@ -75,7 +75,15 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
||||
retries = 0
|
||||
while retries < maxRetries:
|
||||
try:
|
||||
response = httpx.post(
|
||||
if useProxy:
|
||||
# 使用代理
|
||||
logger.debug("使用代理")
|
||||
httpClient = httpx.Client(proxy=proxyUrl, verify=False)
|
||||
else:
|
||||
# 不使用代理
|
||||
logger.debug("不使用代理")
|
||||
httpClient = httpx.Client(verify=False)
|
||||
responseOriginal = httpClient.post(
|
||||
url=endpoint + getSDGBApiHash(targetApi),
|
||||
headers={
|
||||
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
|
||||
@@ -89,20 +97,21 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
||||
content=reqData_deflated,
|
||||
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
|
||||
#verify=certifi.where(),
|
||||
verify=False,
|
||||
#verify=False,
|
||||
timeout=timeout
|
||||
)
|
||||
if not noLog:
|
||||
logger.info(f"{targetApi} 请求结果: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
if not noLog:
|
||||
logger.info(f"{targetApi} 请求结果: {responseOriginal.status_code}")
|
||||
|
||||
if responseOriginal.status_code == 200:
|
||||
logger.debug("200 OK!")
|
||||
else:
|
||||
errorMessage = f"请求失败: {response.status_code}"
|
||||
errorMessage = f"请求失败: {responseOriginal.status_code}"
|
||||
logger.error(errorMessage)
|
||||
raise SDGBRequestError(errorMessage)
|
||||
|
||||
responseRAWContent = response.content
|
||||
responseRAWContent = responseOriginal.content
|
||||
|
||||
try:
|
||||
responseDecompressed = zlib.decompress(responseRAWContent)
|
||||
|
||||
Reference in New Issue
Block a user