Fix proxy test: URL-encode httpx credentials, use Proxy object, improve error detail
DataImpulse username contains semicolons (;sessid.ID) that weren't being URL-encoded in httpx_proxy_url, causing silent parse failures. Also use httpx.Proxy object instead of raw string (consistent with httpx_proxy()), and capture repr(e) so empty-message exceptions show their type. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ed0a027448
commit
f6d5fb27e1
2 changed files with 8 additions and 6 deletions
|
|
@ -280,17 +280,18 @@ async def test_proxy_config(
|
|||
if not (proxy_util.is_enabled(cfg) and cfg['password']):
|
||||
raise HTTPException(status_code=400, detail="Proxy host, username and password must be saved first.")
|
||||
|
||||
proxy_url = proxy_util.httpx_proxy_url(cfg, proxy_util.new_session_id())
|
||||
|
||||
import httpx
|
||||
proxy = proxy_util.httpx_proxy(cfg, proxy_util.new_session_id())
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient(proxy=proxy_url, timeout=40.0) as client:
|
||||
async with httpx.AsyncClient(proxy=proxy, timeout=40.0) as client:
|
||||
resp = await client.get("https://ipinfo.io/json")
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
except Exception as e:
|
||||
logger.warning(f"Proxy test failed: {e}")
|
||||
raise HTTPException(status_code=502, detail=f"Proxy test failed: {e}")
|
||||
detail = repr(e) or str(e) or type(e).__name__
|
||||
logger.warning(f"Proxy test failed: {detail}")
|
||||
raise HTTPException(status_code=400, detail=f"Proxy test failed: {detail}")
|
||||
|
||||
return {
|
||||
'ok': True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue