14 lines
472 B
Python
14 lines
472 B
Python
"""repro: curl 401 时的 stdout 形态"""
|
|
import subprocess
|
|
# 走 localhost
|
|
r = subprocess.run(
|
|
["curl", "-sS", "-m", "8",
|
|
"-w", "\n---HTTP=%{http_code} TIME=%{time_total}---\n",
|
|
"http://127.0.0.1:9999/nonexistent"], # 不存在的端口
|
|
capture_output=True, text=True, timeout=10
|
|
)
|
|
print("=== 不存在的端口(预期:curl 报错,http=000)===")
|
|
print("rc:", r.returncode)
|
|
print("stdout:", repr(r.stdout[:300]))
|
|
print("stderr:", repr(r.stderr[:200]))
|