tools.http_poster module
Universal HTTP request tool supporting any method, headers, cookies, and data.
- async tools.http_poster.run(url, method='GET', headers=None, cookies=None, data=None, json_data=None, form_data=None, params=None, timeout=30.0, verify_ssl=True, follow_redirects=True, proxy=None, ctx=None)[source]
Make an arbitrary HTTP request and return the response details.
Entry point for the
http_requesttool, a general-purpose client supporting any standard method, custom headers/cookies/query params, and a raw, JSON, or form body. It is heavily SSRF-hardened: the target URL is validated and normalized withassert_safe_http_url, outbound headers are sanitized viasafe_http_headers, an optional SOCKS5 proxy is checked withassert_safe_socks_proxy_url, and the request itself runs throughsafe_httpx_clientplussafe_http_request(fromtools._safe_http), which re-validates redirect hops. Disabling TLS verification is privileged:verify_ssl=Falseis honored only when the caller holdsUNSANDBOXED_EXEC(checked viatools.alter_privileges.has_privilegeagainst the Redis-backed store), otherwise it is forced back on. At most one body type may be supplied, and the timeout is clamped to 1-300 seconds.Dispatched by the tool runner in
tools/__init__.py, which calls this module’srun(tool_def.handler(**arguments, ctx=ctx)) for the registeredhttp_requesttool; there are no direct internal callers.- Parameters:
url (
str) – Target URL; must start withhttp://orhttps://.method (
str) – HTTP method; validated againstVALID_METHODSand upper-cased. Defaults toGET.headers (
Optional[str]) – JSON object string of request headers.json_data (
Optional[str]) – JSON string sent as a JSON body (sets the JSON content type).form_data (
Optional[str]) – JSON object string sent as URL-encoded form fields.params (
Optional[str]) – JSON object string of URL query parameters.timeout (
float) – Request timeout in seconds; clamped to 1-300, default 30.verify_ssl (
bool) – Whether to verify TLS certificates; forcedTrueunless the caller hasUNSANDBOXED_EXEC.follow_redirects (
bool) – Whether redirects are followed (up to 5).proxy (
Optional[str]) – Optional validated SOCKS5 proxy URL (socks5/socks5h); omit for a direct connection.ctx – Tool execution context; supplies
redis,config, anduser_idfor the TLS-off privilege check.
- Returns:
JSON. On success an object with
status_code,headers,body, the finalurl, andelapsed_ms; on failure an{"error": ..., "details": ...}object (bad input, blocked URL, timeout, connection failure, too many redirects, etc.).- Return type: