Expand description
API block — HTTP request via reqwest. Honors {{...}} interpolation
in url, headers, and body.
Config (node.data):
method— “GET” / “POST” / “PUT” / “DELETE” / “PATCH” (default GET)url— required; supports{{...}}headers— optional{ name: value }map; values support{{...}}body— optional string body (POST/PUT/PATCH); supports{{...}}auth— optional{ vault: "<entry>", as: "bearer" | "header:<Name>" }: a Vault entry’s value sent as that header. Seesuper::api_authfor what keeps it on the one site the drone names; the first call asks the person.
Output:
{ "status": 200, "body": <parsed-json-or-text>, "headers": { ... } }A response is read up to MAX_RESPONSE_BYTES; a longer one is an error.
Structs§
- Credential 🔒
- What a call with a Vault credential sends it as, and what takes it out of the answer.
Constants§
- DEFAULT_
TIMEOUT_ 🔒MS - MAX_
RESPONSE_ 🔒BYTES - The most of a response a call reads: a drone’s ledger is not where a download goes.
Statics§
- CREDENTIAL_
CLIENT 🔒 - The client for a call with a Vault credential: it follows no redirect, so the credential goes to the one site the drone names and nowhere a response points.
- HTTP_
CLIENT 🔒 - Shared
reqwest::Clientso drones with multiple API blocks reuse one connection pool instead of building a new pool per request. Per-request timeouts move to the RequestBuilder. (reagent P2 on PR #755.)
Functions§
- clean 🔒
textwith the credential taken out of it, when the call had one.- credential 🔒
- Checks and resolves the node’s
auth, asking the person the first time.Nonewhen the node has none. Nothing is sent, and nothing but the person’s answer is waited for. - credential_
client 🔒 - exchange 🔒
- Send the request and read the whole answer. A timeout says nothing about whether the other side did the work, so it is worded apart from a failure to connect: the retry policy runs the second again and never the first.
- http_
client 🔒 - is_
reserved_ 🔒v4 - is_
reserved_ 🔒v6 - read_
capped 🔒 - The response’s body up to
MAX_RESPONSE_BYTES. - read_
error 🔒 - A failure while reading the body: a timeout is worded apart from the rest (see
exchange). - run
- validate_
url_ 🔒for_ safety - Same checks as
validate_url_safetybut takes a pre-parsedreqwest::Url. The redirect-policy closure receives Url values directly, so this avoids a parse round-trip on every hop. - validate_
url_ 🔒safety - Validate a resolved URL before dispatching it. Phase 1 SSRF
protection: rejects non-http(s) schemes and literal-IP hosts that
fall into reserved / link-local / private / loopback ranges (the
AWS metadata endpoint 169.254.169.254, RFC1918 space, 127.0.0.1,
fc00::/7, ::1, etc.). DNS-resolved hostnames are not re-checked
post-resolution — that requires a custom
reqwestresolver and lands as a follow-up issue. See kimi P1 on PR #755.