# reqwest HTTP 客户端库 ## 功能 reqwest(url) 创建同步 HTTP 请求构建器,支持 method、header、cookie、cookie_store、body、json、form、multipart、timeout、query、proxy、redirect_policy 和 send。 ## API 列表 | API | 说明 | | ------ | ------ | | [reqwest.method](/zh-hans/docs/reqwest/method) | 设置 HTTP 请求方法。 | | [reqwest.header](/zh-hans/docs/reqwest/header) | 设置一个或一组请求头。 | | [reqwest.cookie](/zh-hans/docs/reqwest/cookie) | 设置 Cookie 请求头。 | | [reqwest.cookie_store](/zh-hans/docs/reqwest/cookie_store) | 启用或关闭当前请求客户端的 Cookie 存储。 | | [reqwest.body](/zh-hans/docs/reqwest/body) | 设置字符串请求体。 | | [reqwest.json](/zh-hans/docs/reqwest/json) | 设置 JSON 请求体。 | | [reqwest.form](/zh-hans/docs/reqwest/form) | 设置 application/x-www-form-urlencoded 表单请求体。 | | [reqwest.multipart](/zh-hans/docs/reqwest/multipart) | 设置 multipart/form-data 请求体。 | | [reqwest.timeout](/zh-hans/docs/reqwest/timeout) | 设置请求超时时间。 | | [reqwest.query](/zh-hans/docs/reqwest/query) | 追加 URL 查询参数。 | | [reqwest.proxy](/zh-hans/docs/reqwest/proxy) | 设置 HTTP/HTTPS 代理。 | | [reqwest.redirect_policy](/zh-hans/docs/reqwest/redirect_policy) | 设置重定向策略。 | | [reqwest.send](/zh-hans/docs/reqwest/send) | 同步发送 HTTP 请求并返回响应对象。 | ## 示例 ```bt response = reqwest('https://example.com').send() result = type(response) // 输出:Object print result ``` ## 注意事项 - 当前 VM 是同步模型,send() 会同步等待 HTTP 请求完成;底层复用进程级 I/O runtime。 - 默认启用 HTTP client 池,按代理和重定向策略分组复用;池状态可通过 `BT.stats().http` 查看。 - `cookie_store(true)` 只作用于本次 `send()` 及其重定向链路,不进入共享 client 池,避免跨请求 Cookie 污染。 - body、json、form、multipart 都会设置请求体;同一请求中最后一次设置的请求体生效。 HTTP client 池默认配置: | 环境变量 | 默认值 | 说明 | | ------ | ------ | ------ | | BT_HTTP_CLIENT_POOL | true | 是否启用 HTTP client 池。 | | BT_HTTP_CLIENT_POOL_LIMIT | 32,最大 1024 | 最多保留的 client 配置分组数量。 | | BT_HTTP_CLIENT_IDLE_TTL_MS | 300000 | client 空闲保留时间,单位毫秒;0 表示不按空闲时间淘汰。 | | BT_HTTP_SLOW_MS | 0 | 慢 HTTP 调用日志阈值,单位毫秒;0 表示关闭。 |