Class: Legate::Tools::HttpRequest
- Inherits:
-
Legate::Tool
- Object
- Legate::Tool
- Legate::Tools::HttpRequest
- Includes:
- Base::HttpClient
- Defined in:
- lib/legate/tools/http_request_tool.rb
Overview
General-purpose HTTP client tool.
Makes a request to a URL and returns the status code, response headers, and body. It is SSRF-safe (private/loopback/link-local hosts are blocked and the connection is pinned to the validated IP) and auth-aware (configured auth URL-mappings are applied automatically; pass ‘headers` for manual auth).
A non-2xx response is returned as a normal result (with its status_code) so an agent can inspect it; only network/SSRF/timeout failures are errors.
Constant Summary collapse
- MAX_BODY_BYTES =
Cap the returned body so a large download can’t blow up the context/LLM.
1_000_000- ALLOWED_METHODS =
%w[GET POST PUT PATCH DELETE HEAD].freeze
Instance Attribute Summary
Attributes included from Base::HttpClient
Attributes inherited from Legate::Tool
#description, #name, #parameters
Instance Method Summary collapse
-
#initialize(**options) ⇒ HttpRequest
constructor
A new instance of HttpRequest.
Methods included from Base::HttpClient
#http_delete, #http_get, #http_head, #http_post, #http_put
Methods inherited from Legate::Tool
define_metadata, #execute, inherited, #validate_and_coerce_params, #validate_params
Methods included from Legate::Tool::MetadataDsl
Constructor Details
#initialize(**options) ⇒ HttpRequest
Returns a new instance of HttpRequest.
42 43 44 45 46 |
# File 'lib/legate/tools/http_request_tool.rb', line 42 def initialize(**) super(**) # Targets are passed absolute per-request; the base URL is only a required placeholder. setup_http_client(base_url: 'https://placeholder.invalid') end |