pub struct HttpRequestTool { /* private fields */ }Expand description
HTTP 请求工具:发送 HTTP 请求。
安全限制:
- 禁止访问内网资源(防止 SSRF 攻击)
- 支持域名白名单/黑名单
- 限制重定向次数
- 限制响应体大小
适用场景:
- 发送 HTTP 请求
- 获取网页内容
输入格式:
{
"method": "GET",
"url": "https://example.com",
"headers": {
"Accept": "text/html"
},
"body": "请求体",
"timeout": 60 // 可选,超时时间(秒)
}Implementations§
Source§impl HttpRequestTool
impl HttpRequestTool
Sourcepub fn with_allowed_domains(self, domains: Vec<String>) -> Self
pub fn with_allowed_domains(self, domains: Vec<String>) -> Self
设置允许的域名白名单
Sourcepub fn with_blocked_domains(self, domains: Vec<String>) -> Self
pub fn with_blocked_domains(self, domains: Vec<String>) -> Self
设置禁止的域名黑名单
Sourcepub fn with_max_redirects(self, max: u32) -> Self
pub fn with_max_redirects(self, max: u32) -> Self
设置最大重定向次数
Trait Implementations§
Source§impl Default for HttpRequestTool
impl Default for HttpRequestTool
Source§impl Tool for HttpRequestTool
impl Tool for HttpRequestTool
Source§fn categories(&self) -> &'static [ToolCategory]
fn categories(&self) -> &'static [ToolCategory]
工具分类 Read more
Source§fn input_schema(&self) -> Value
fn input_schema(&self) -> Value
工具输入参数的 schema Read more
Source§fn call<'life0, 'async_trait>(
&'life0 self,
input: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn call<'life0, 'async_trait>(
&'life0 self,
input: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
执行工具 Read more
Source§fn definition(&self) -> ToolDefinition
fn definition(&self) -> ToolDefinition
获取工具定义 (ToolDefinition) Read more
Auto Trait Implementations§
impl Freeze for HttpRequestTool
impl RefUnwindSafe for HttpRequestTool
impl Send for HttpRequestTool
impl Sync for HttpRequestTool
impl Unpin for HttpRequestTool
impl UnsafeUnpin for HttpRequestTool
impl UnwindSafe for HttpRequestTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more