Karta. NetGuard. HTTP
(Karta v1.0.0)
One HTTP request to a URL that someone else gave Karta (a webhook's
URL), through Karta.NetGuard:
- Where. The URL's host is resolved once by
Karta.NetGuard.resolve/2(an address in the URL is checked the same way); refused addresses are never connected to. Karta connects to the checked addresses themselves, in order, until one accepts the connection: no second lookup, so a name that resolves to another address the next time (DNS rebinding) changes nothing. The request still names the host: theHostheader, and forhttpsthe TLS server name (SNI) and the name the certificate must be valid for. - TLS. For
https, TLS 1.2 or 1.3 and a certificate that chains to a trusted root (the operating system's, or:cacerts) and is valid for the host (RFC 6125, wildcards allowed). - HTTP. HTTP/1.1, one request per connection. A redirect is an answer like any other: it is never followed.
- Limits. The whole request, every address and every read, must
end within
:timeout(default 15 s). At most:max_bodybytes of the answer's body are read (default 16 KiB); the rest is not read, and the answer saystruncated: true.
Returns {:ok, %{status:, headers:, body:, truncated:, address:}} (the
address connected to, as text) or {:error, reason} with the reason in
words.
Options: :timeout, :max_body, :cacerts, and :dns,
:allowed_networks, :blocked_networks for Karta.NetGuard.
Summary
Functions
Checks that Karta may connect to the URL's host: an address in the URL is
checked, and a name is resolved and every address checked
(Karta.NetGuard), as a request to it would be. The lookup happens now,
so a name that later resolves elsewhere is still checked then.
Checks a URL that is to be stored for later requests: http or https,
a host, no user name or password, no fragment. Its host is not
resolved: that happens at each request.
Sends one request. See the module doc.
Types
Functions
Checks that Karta may connect to the URL's host: an address in the URL is
checked, and a name is resolved and every address checked
(Karta.NetGuard), as a request to it would be. The lookup happens now,
so a name that later resolves elsewhere is still checked then.
Checks a URL that is to be stored for later requests: http or https,
a host, no user name or password, no fragment. Its host is not
resolved: that happens at each request.
@spec request(String.t(), String.t(), [{String.t(), String.t()}], iodata(), keyword()) :: {:ok, response()} | {:error, String.t()}
Sends one request. See the module doc.