Class: Legate::Tools::HttpRequest

Inherits:
Legate::Tool show all
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

#http_base_url, #http_client

Attributes inherited from Legate::Tool

#description, #name, #parameters

Instance Method Summary collapse

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

included

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(**options)
  super(**options)
  # Targets are passed absolute per-request; the base URL is only a required placeholder.
  setup_http_client(base_url: 'https://placeholder.invalid')
end