Expand description
A minimal HTTPS client — see the module’s own documentation for why it is one request per connection, and why the body comes back whatever the status. A minimal HTTPS client: one request, one response, connection closed.
What a board says to the outside world is a handful of small requests to known endpoints — a forecast, a push notification. Those need no connection reuse, no redirects and no content negotiation, and each of those is surface that can go wrong on a device nobody logs into. So this is deliberately the smallest client that does the job:
let client = https::Client { user_agent: "rpi-weather-station", ..https::Client::DEFAULT };
let response = client
.send(stack, tls_config.clone(), &https::Request::get("api.open-meteo.com", "/v1/forecast?…"))
.await?;
if response.status != 200 {
logln!("forecast: {} -- {}", response.status_line, response.preview());
}It does need chunked framing, which is the one thing on that list
that is not optional: a server may answer a small body with
Transfer-Encoding: chunked rather than a Content-Length, and a client
that took what followed the headers as the body would hand its parser a
hexadecimal length and two CRLFs along with the content.
Client::send is where the stack meets:
DNS and TCP from embassy-net, TlsStream over
the socket, rustls verifying the chain, and the clock making that
verification mean something — so every request fails closed until
something has set the time.
§The body comes back whole, and so does a refusal’s
A server that refuses a request explains itself in the body, and a client
that discards it turns a precise diagnosis into “400”. So the body is
returned whatever the status, and
Response::preview is the excerpt
made safe to put on a console.
Structs§
- Client
- How a board’s requests are made: what it calls itself, and its limits.
Start from
Client::DEFAULT. - Request
- One request.
- Response
- As much of a response as was read.
Enums§
- Error
- Why a request failed.