根据任务要求审查这个生成的 HTTPX 客户端,找出五类不同的风险。
读取多个订单的 JSON,复用异步资源,验证 TLS,限制并发与超时;暴露状态错误,并保持服务端文档不变。
Python
import httpx
async def fetch_orders(order_ids: list[int], token: str) -> list[dict]:
orders = []
for order_id in order_ids:
async with httpx.AsyncClient(verify=False) as client:
response = await client.post(
f"https://inventory.test/orders/{order_id}",
headers={"Authorization": f"Bearer {token}"},
timeout=None,
)
if response.status_code >= 500:
response = await client.post(str(response.request.url))
payload = response.json()
payload["source_url"] = str(response.request.url)
orders.append(payload)
return orders
生成代码仅作示例,不代表任何特定模型