Capy-Bearer Documentation

http_request

host call

Capy

function http_request(request : dval) dval

Description

http_request() sends an outbound HTTP or HTTPS request. Set method, url, headers, body, timeout_ms, and follow_redirects as needed.

When you set a security field, set https_only, public_dns_only, pin_dns, isolated_curl, and no_redirects to true.

Parameters

request : a map that describes an outbound request

Return Values

A map with status, headers, body, and error.

Errors

The result can report invalid_request, unsafe_dns, timeout, response_too_large, redirect_not_allowed, http_status, or network_failure.

Example

Capy

var outbound := dval({"method": "GET", "url": "http://127.0.0.1/tests/capy-render.capy", "headers": {"Host": "bearer.openfu.com"}, "timeout_ms": 2000})
var response := http_request(outbound)
print("status=", s32(response["status"]), "\n")