http-toolkit-intercept
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHTTP Toolkit Intercept
HTTP Toolkit 拦截操作指南
Use this skill when you need authoritative evidence of what your program sent to a remote API and what it received back while verifying a code change. Works across any runtime — Node.js, Bun, Deno, Python, Go, Ruby, Java/JVM, .NET, PHP, Rust, shell scripts, etc. — as long as the process respects a proxy.
The reliable pattern is:
- Start HTTP Toolkit correctly.
- Run the program through the proxy in a mode that produces a machine-readable log (e.g. , debug logging, or structured stdout).
--output-format json - Export outbound HTTP requests from HTTP Toolkit.
- Pair the outbound HTTP export with the inbound program session log.
Do not rely on TUI screenshots alone when the question is about request payloads, auth headers, or wire-level behavior.
当你需要在验证代码变更时,获取程序发送给远程API的内容以及收到的响应的权威证据时,可以使用该方法。它适用于任意运行时——Node.js、Bun、Deno、Python、Go、Ruby、Java/JVM、.NET、PHP、Rust、shell脚本等——只要进程支持代理即可。
可靠的操作流程如下:
- 正确启动HTTP Toolkit。
- 通过代理以生成机器可读日志的模式运行程序(例如、调试日志或结构化标准输出)。
--output-format json - 从HTTP Toolkit导出出站HTTP请求。
- 将出站HTTP导出内容与入站程序会话日志配对。
不要仅依赖TUI截图来排查请求 payload、认证头或网络层面行为的问题。
Prerequisites / Known-Good Launch
前置条件 / 可靠启动方式
Start HTTP Toolkit
启动HTTP Toolkit
On Linux/headless environments, plain often fails due to sandbox/X11 issues. Prefer:
httptoolkitbash
xvfb-run --auto-servernum httptoolkit --no-sandboxIf a stale server is already running on ports , stop it first:
45456/45457bash
pkill -f "HTTP Toolkit Server|httptoolkit|xvfb-run --auto-servernum httptoolkit" || true在Linux/无头环境中,直接运行通常会因沙箱/X11问题失败。建议使用:
httptoolkitbash
xvfb-run --auto-servernum httptoolkit --no-sandbox如果端口上已有过期服务器在运行,请先停止它:
45456/45457bash
pkill -f "HTTP Toolkit Server|httptoolkit|xvfb-run --auto-servernum httptoolkit" || trueVerify the proxy is reachable
验证代理是否可达
bash
undefinedbash
undefinedHTTP Toolkit's admin API lives on port 45456/45457 by default.
HTTP Toolkit的管理API默认运行在端口45456/45457。
Treat 200/401/403 as "reachable"; only connection failure means the server is dead.
返回200/401/403即表示“可达”;只有连接失败才意味着服务器未运行。
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:45456/config
undefinedcurl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:45456/config
undefinedQuick Start
快速开始
1. Launch your program with the proxy env vars set
1. 设置代理环境变量后启动程序
The canonical env vars most runtimes honor:
bash
HTTP_PROXY="http://127.0.0.1:8000" \
HTTPS_PROXY="http://127.0.0.1:8000" \
ALL_PROXY="http://127.0.0.1:8000" \
NO_PROXY="" \
<your-program> <args>Some runtimes require an extra env var or flag — see the "Runtime proxy matrix" below.
If the HTTP Toolkit CA is not trusted by your runtime, TLS verification will fail. See "TLS Safety" below. Disabling TLS verification is appropriate only for controlled local debugging.
大多数运行时认可的标准环境变量:
bash
HTTP_PROXY="http://127.0.0.1:8000" \
HTTPS_PROXY="http://127.0.0.1:8000" \
ALL_PROXY="http://127.0.0.1:8000" \
NO_PROXY="" \
<your-program> <args>部分运行时需要额外的环境变量或标志——请查看下方的“运行时代理矩阵”。
如果你的运行时未信任HTTP Toolkit CA,TLS验证将会失败。请查看下方的“TLS安全说明”。仅在受控的本地调试场景下,才适合禁用TLS验证。
2. Capture the inbound session log
2. 捕获入站会话日志
If your program supports a machine-readable output mode (e.g. , , , structured stdout, or writing to a file), pipe it to a file:
--output-format stream-json--json--log-level debugbash
<your-program> exec --output-format stream-json "your input" \
> /tmp/session-stdout.log 2> /tmp/session-stderr.log如果你的程序支持机器可读输出模式(例如、、、结构化标准输出或写入文件),将其输出重定向到文件:
--output-format stream-json--json--log-level debugbash
<your-program> exec --output-format stream-json "your input" \
> /tmp/session-stdout.log 2> /tmp/session-stderr.log3. Export outbound HTTP from HTTP Toolkit
3. 从HTTP Toolkit导出出站HTTP请求
Either:
- Use the HTTP Toolkit GUI export (File → Export → JSON / HAR), or
- Hit the admin API directly. The exact endpoint depends on your HTTP Toolkit version; inspect DevTools in the HTTP Toolkit UI to see the requests it makes.
可以选择:
- 使用HTTP Toolkit GUI导出(文件 → 导出 → JSON / HAR),或者
- 直接调用管理API。具体端点取决于你的HTTP Toolkit版本;可在HTTP Toolkit UI的开发者工具中查看它发起的请求。
4. Cross-reference the two streams
4. 交叉引用两个流
- Outbound HTTP (from HTTP Toolkit): authoritative for request bodies, headers, auth tokens, retry timing.
- Inbound session log (from the program): authoritative for how your code reacted to the responses.
Together they answer: "what did we send?" and "what did we do with the response?"
- 出站HTTP请求(来自HTTP Toolkit):是请求体、请求头、认证令牌、重试时机的权威来源。
- 入站会话日志(来自程序):是代码如何响应返回结果的权威来源。
两者结合可以回答:“我们发送了什么?”以及“我们对响应做了什么处理?”
What finally worked for payload verification
有效验证Payload的方法
The critical correct pathways that proved reliable were:
-
Use a non-interactive / exec mode, not the TUI, when verifying payloads
- Interactive TUIs are slower and much harder to analyze.
- Use whatever your program has for scripting (,
--output-format,--json,--headless).--batch
-
Treat outbound and inbound as separate evidence sources
- HTTP Toolkit gives outbound HTTP requests.
- The program's session log gives inbound assistant/tool/application behavior.
- You need both to answer: "what did the remote return?" and "what did the program actually do with it?"
-
Set the proxy env vars your specific runtime honors
- /
HTTP_PROXYcover most runtimes, but some (e.g. Bun, Java) require extra vars or flags.HTTPS_PROXY - See the "Runtime proxy matrix" below.
-
Disable TLS verification only for controlled local debugging when needed
- If the HTTP Toolkit CA is not trusted locally, use the runtime-specific escape hatch to skip verification.
- Prefer trusting the CA in your OS / language trust store instead.
- Never disable TLS in production repros.
-
Keep runs bounded
- Long network-heavy sessions can take time.
- If you only need to prove request shape, export after the relevant request is observed — you do not always need to wait for full completion.
经过验证的可靠关键步骤如下:
-
验证Payload时使用非交互/执行模式,而非TUI
- 交互式TUI速度较慢,且分析难度大得多。
- 使用程序提供的脚本化方式(、
--output-format、--json、--headless等)。--batch
-
将出站和入站视为独立的证据来源
- HTTP Toolkit提供出站HTTP请求信息。
- 程序的会话日志提供入站助手/工具/应用的行为信息。
- 你需要两者结合才能回答:“远程服务返回了什么?”以及“程序实际对它做了什么处理?”
-
设置你的特定运行时认可的代理环境变量
- /
HTTP_PROXY适用于大多数运行时,但部分运行时(如Bun、Java)需要额外的变量或标志。HTTPS_PROXY - 请查看下方的“运行时代理矩阵”。
-
仅在必要时,于受控本地调试场景下禁用TLS验证
- 如果本地未信任HTTP Toolkit CA,请使用运行时特定的规避方式跳过验证。
- 优先选择在你的操作系统/语言信任存储中信任该CA。
- 绝不要在生产环境复现问题时禁用TLS。
-
限制运行时长
- 长时间的网络密集型会话会耗费较多时间。
- 如果你仅需要验证请求结构,在观察到相关请求后即可导出——无需等待整个会话完成。
Key Facts
关键要点
- Proxy env vars are runtime-specific — know which ones your runtime honors
- HTTP Toolkit admin API is request-oriented — outbound HTTP comes from HTTP Toolkit, inbound behavior comes from the program log
- TLS is verified by default — runtime-specific skip flags are local-dev escape hatches only
- 代理环境变量因运行时而异——了解你的运行时认可哪些变量
- HTTP Toolkit管理API面向请求——出站HTTP请求信息来自HTTP Toolkit,入站行为信息来自程序日志
- 默认启用TLS验证——运行时特定的跳过标志仅适用于本地开发场景
Runtime proxy matrix
运行时代理矩阵
| Runtime | Proxy env vars / flags | TLS bypass (local dev only) |
|---|---|---|
| Node.js | | |
| Bun | | |
| Deno | | |
Python ( | | |
Python ( | Same env vars | |
Go ( | | |
| Ruby | | |
| Java / JVM | | Import CA into a truststore and pass |
| .NET / C# | | Trust CA in OS store, or |
| PHP (curl / cli) | | |
Rust ( | | |
| curl / shell | | |
| Docker containers | Pass env vars through with | Mount the CA into the image and install it, or use runtime-specific bypass flags |
Prefer trusting the HTTP Toolkit CA in your runtime/OS trust store over disabling verification. Bypass flags should be local-dev only.
| 运行时 | 代理环境变量/标志 | TLS绕过(仅本地开发) |
|---|---|---|
| Node.js | | |
| Bun | | |
| Deno | | |
Python ( | | |
Python ( | 相同环境变量 | |
Go ( | | |
| Ruby | | |
| Java / JVM | | 将CA导入信任存储并传入 |
| .NET / C# | | 在操作系统存储中信任CA,或设置 |
| PHP (curl / cli) | | |
Rust ( | | 在客户端设置 |
| curl / shell | | |
| Docker容器 | 通过 | 将CA挂载到镜像中并安装,或使用运行时特定的绕过标志 |
优先选择在你的运行时/操作系统信任存储中信任HTTP Toolkit CA,而非禁用验证。绕过标志仅应在本地开发场景下使用。
TLS Safety Guardrails
TLS安全防护
- Keep TLS verification enabled whenever possible.
- Prefer trusting the HTTP Toolkit CA in your local trust store instead of disabling verification.
- Use runtime-specific TLS-bypass flags only for controlled local debugging in development.
- Never disable TLS when intercepting production traffic.
- 尽可能保持TLS验证启用状态。
- 优先选择在本地信任存储中信任HTTP Toolkit CA,而非禁用验证。
- 仅在受控的本地开发调试场景下使用运行时特定的TLS绕过标志。
- 拦截生产流量时绝不要禁用TLS。
Inspecting Captured Logs
检查捕获的日志
Filter to relevant events only
仅筛选相关事件
If your program emits newline-delimited JSON, use :
jqbash
jq -c 'select(.type == "tool_call" or .type == "message")' /tmp/session-stdout.logAdjust the filter to match your program's event schema. For plain-text logs, use / patterns.
rggrep如果你的程序输出换行分隔的JSON,可使用:
jqbash
jq -c 'select(.type == "tool_call" or .type == "message")' /tmp/session-stdout.log根据程序的事件模式调整筛选条件。对于纯文本日志,使用/模式。
rggrepMatch outbound HTTP to inbound events
匹配出站HTTP请求与入站事件
Sort both streams by timestamp, then interleave them. The sequence usually looks like:
outbound POST /api/endpoint (from HTTP Toolkit)
inbound event received (from program log)
inbound follow-up action (from program log)
outbound POST /api/endpoint (next request)If a program log shows an outbound request that HTTP Toolkit didn't capture, that's a proxy-config bug.
将两个流按时间戳排序,然后交叉对比。序列通常如下:
outbound POST /api/endpoint (来自HTTP Toolkit)
inbound event received (来自程序日志)
inbound follow-up action (来自程序日志)
outbound POST /api/endpoint (下一个请求)如果程序日志显示有出站请求,但HTTP Toolkit未捕获到,说明代理配置存在问题。
Troubleshooting
故障排查
| Problem | Cause | Fix |
|---|---|---|
| Program hangs, no events after startup | Proxy env vars not reaching the process, or TLS verification blocking | Re-run with the right env vars for your runtime (see matrix); if necessary, enable the runtime's TLS bypass in dev |
| Runtime-specific proxy env var missing (e.g. | Use the correct runtime-specific proxy config |
| TLS cert errors via proxy | MITM CA not trusted by this runtime | Trust HTTP Toolkit CA in the runtime / OS store, or enable the runtime's TLS bypass in dev only |
HTTP Toolkit API 403s on | Auth-gated config endpoint | Treat 200/401/403 as reachable; only connection failure means the server is dead |
| Export has outbound data but no matching inbound events | Didn't capture the program log | Add |
| HTTP Toolkit misses the first request | Started capturing after the process launched | Start HTTP Toolkit first, THEN launch the program |
Container / VM can't reach | Loopback is container-local | Use |
| Program ignores env vars entirely | Runtime doesn't honor env vars (e.g. JVM) | Use runtime-specific flags ( |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| 程序启动后挂起,无任何事件 | 代理环境变量未传递到进程,或TLS验证被阻止 | 使用适合你运行时的正确环境变量(见矩阵);必要时在开发环境启用运行时的TLS绕过 |
每次请求均出现 | 缺少运行时特定的代理环境变量(如Bun的 | 使用正确的运行时特定代理配置 |
| 通过代理时出现TLS证书错误 | MITM CA未被该运行时信任 | 在运行时/操作系统存储中信任HTTP Toolkit CA,或仅在开发环境启用运行时的TLS绕过 |
HTTP Toolkit API调用 | 配置端点受认证限制 | 返回200/401/403均视为可达;只有连接失败才意味着服务器未运行 |
| 导出内容包含出站数据,但无匹配的入站事件 | 未捕获程序日志 | 在启动命令中添加 |
| HTTP Toolkit未捕获第一个请求 | 在进程启动后才开始捕获 | 先启动HTTP Toolkit,再启动程序 |
容器/虚拟机无法访问 | 回环地址仅在容器内部有效 | 使用 |
| 程序完全忽略环境变量 | 运行时不认可环境变量(如JVM) | 使用运行时特定的标志(如JVM的 |