Expand description
http-query is a client and server SDK for the HTTP QUERY method
(RFC 10008).
QUERY is a safe, idempotent request method that carries a request body
describing a query to be evaluated against the target resource. Unlike GET,
the query travels in the body rather than the URI; unlike POST, the request
is safe and may be retried and cached.
§Sending a query (requires the client feature, enabled by default)
use http_query::Client;
let client = Client::new();
let resp = client
.query_string("https://example.org/search", "application/sql", "SELECT 1")
.await?;
println!("status: {}", resp.status());§Discovering support
Client::options issues an OPTIONS request and reports QUERY support
from the Allow and Accept-Query header fields. Accept-Query is parsed
as an RFC 9651 Structured Fields list.
§Result vs. equivalent resource
A response may advertise two distinct URIs (RFC 10008 §2.3–2.4):
Content-Location (the stored result, Client::fetch_result) and
Location (the equivalent resource whose GET re-runs the query,
Client::fetch_equivalent).
§Serving QUERY
The server module provides framework-agnostic helpers to validate an
incoming QUERY request and advertise support. See examples/axum_server.rs.
Modules§
- server
- Framework-agnostic helpers for serving the QUERY method.
Structs§
- Client
- An async client for sending HTTP QUERY requests.
- Discovery
- A server’s advertised support for the QUERY method.
- Response
Info - QUERY-relevant metadata extracted from a response.
Enums§
- Error
- Errors returned by the
http-queryclient and helpers.
Constants§
- HEADER_
ACCEPT - The
Acceptheader field name. - HEADER_
ACCEPT_ QUERY - The
Accept-Queryheader field name (RFC 10008 §3). - HEADER_
ALLOW - The
Allowheader field name. - HEADER_
CONTENT_ LOCATION - The
Content-Locationheader field name. - HEADER_
CONTENT_ TYPE - The
Content-Typeheader field name. - HEADER_
LOCATION - The
Locationheader field name. - MEDIA_
TYPE_ FORM - The
application/x-www-form-urlencodedmedia type. - MEDIA_
TYPE_ JSON - The
application/jsonmedia type. - METHOD_
QUERY - The HTTP QUERY method token, as defined by RFC 10008.
Functions§
- cache_
key - Computes a stable cache key for a QUERY request.
- check_
status - Validates a response’s status, turning a non-2xx status into
Error::Status(consuming the body for the error message). - format_
accept_ query - Serializes media ranges into a valid Structured Fields List for the
Accept-Queryheader field, quoting values that are not valid Tokens. - matches_
media_ range - Reports whether
media_typeis covered by the advertisedmedia_range, honoring the*/*andtype/*wildcards. Comparison is case-insensitive. - parse_
accept_ query - Parses one or more
Accept-Queryheader field values into the list of advertised media ranges (unquoted, without parameters). - query_
method - Returns the
http::Methodvalue for QUERY. - supports_
query - Reports whether a response advertises support for the QUERY method.
Type Aliases§
- Result
- A specialized
Resultfor this crate.