Downloads for the EU list file: a typed HttpError, text bodies that survive any content type, HEAD-based change detection, and a clear error for a file over http.max-response-bytes.

Values

USER_AGENT

USER_AGENT: Str "hot-dev-eu-sanctions-pkg/0.1 (+https://hot.dev)"

Functions

body-snippet

fn (body: Any): Str

body-text

fn (response: Any): Str

The response body as text: the decoded string when Hot kept it as one, otherwise the body bytes decoded as UTF-8 (a CSV served as application/octet-stream, or a body that happened to parse as JSON).

get-text

fn (url: Str, needed-bytes: Int): Str

GET the list file as text: the body as a Str, or an Err. A response over http.max-response-bytes is an Err saying to raise the cap to needed-bytes. The server ignores Range requests, so a chunked download can't help.

fn (url: Str): Map

HEAD a list file and return {etag, last-modified, content-length, accept-ranges} (each null when not sent). Refreshes compare these with the cached version. A conditional GET would save no request: a changed file over the response cap still needs this HEAD for its size and Range support.

fn (response: Any, name: Str): Str?

A response header by lower-case name, or null.

http-error

fn (response: ::hot::http/HttpResponse, url: Str): HttpError

Build an HttpError from a non-2xx response. Exposed for testing; every request uses it.

is-size-limit-error

fn (result: Result): Bool

True when a request failed because the response exceeded http.max-response-bytes.

request

fn (method: Str, url: Str, headers: Map, body: Any): ::hot::http/HttpResponse

One request with the package User-Agent. Returns the HttpResponse on 2xx, or an Err carrying HttpError (transport failures pass through as their own Err).

too-large-message

fn (url: Str, needed-bytes: Int): Str

The error for a file over http.max-response-bytes, saying how far to raise it. Exposed for testing.

Types

HttpError

HttpError type {
    status: Int,
    url: Str,
    headers: Map,
    body: Any,
    message: Str
}

A non-2xx response from the EU list server. url is the requested URL (without credentials); message is a one-line summary.