Skip to content

Commit c81f180

Browse files
committed
Update HTTP request handling to ignore environment proxies and configure logging for httpx
1 parent f1e98b3 commit c81f180

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

app/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ async def request_get(url: str):
3535
Response: A Response object.
3636
"""
3737
response = None
38-
async with httpx.AsyncClient() as client:
38+
# Explicitly ignore env proxies; k8s envs often inject HTTP(S)_PROXY which can
39+
# return 503 from the proxy rather than the upstream service.
40+
async with httpx.AsyncClient(trust_env=False) as client:
3941
try:
4042
response = await client.get(url, timeout=REQUEST_TIMEOUT)
4143
except httpx.TimeoutException:
@@ -53,7 +55,7 @@ async def request_get(url: str):
5355

5456
async def request_post(url: str, data):
5557
response = None
56-
async with httpx.AsyncClient() as client:
58+
async with httpx.AsyncClient(trust_env=False) as client:
5759
try:
5860
response = await client.post(url, timeout=REQUEST_TIMEOUT, data=data)
5961
except httpx.TimeoutException:

logging.conf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
[loggers]
2-
keys=root
2+
keys=root, httpx
3+
4+
[logger_httpx]
5+
level=CRITICAL
6+
handlers=consoleHandler
7+
qualname=httpx
38

49
[handlers]
510
keys=consoleHandler,detailedConsoleHandler

0 commit comments

Comments
 (0)