Expand description
A minimal HTTP client driven by a .http-style buffer, sent with the
pure-Rust ureq client.
The buffer format (a common “REST client” shape):
POST https://api.example.com/things
Content-Type: application/json
Authorization: Bearer TOKEN
{"name": "widget"}The first non-blank, non-comment line is METHOD url (the method is optional
and defaults to GET); following lines up to a blank line are Header: value;
everything after the blank line is the request body. Lines starting with #
or // are comments. Parsing is pure and unit-tested; send performs the
(blocking) request and is meant to be called from a background thread.
Structs§
- Request
- A parsed HTTP request.
Functions§
- parse_
request - Parse a
.http-style buffer into aRequest. ReturnsNoneif there is no request line with a URL. - send
- Perform
req(blocking) and format the response as text: a status line, the response headers, a blank line, then the body. On a transport error, returnsErrwith the message; on an HTTP error status (4xx/5xx), returns the formatted error response asOk(it is still a real response to show).