Skip to main content

Crate http_query

Crate http_query 

Source
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.
ResponseInfo
QUERY-relevant metadata extracted from a response.

Enums§

Error
Errors returned by the http-query client and helpers.

Constants§

HEADER_ACCEPT
The Accept header field name.
HEADER_ACCEPT_QUERY
The Accept-Query header field name (RFC 10008 §3).
HEADER_ALLOW
The Allow header field name.
HEADER_CONTENT_LOCATION
The Content-Location header field name.
HEADER_CONTENT_TYPE
The Content-Type header field name.
HEADER_LOCATION
The Location header field name.
MEDIA_TYPE_FORM
The application/x-www-form-urlencoded media type.
MEDIA_TYPE_JSON
The application/json media 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-Query header field, quoting values that are not valid Tokens.
matches_media_range
Reports whether media_type is covered by the advertised media_range, honoring the */* and type/* wildcards. Comparison is case-insensitive.
parse_accept_query
Parses one or more Accept-Query header field values into the list of advertised media ranges (unquoted, without parameters).
query_method
Returns the http::Method value for QUERY.
supports_query
Reports whether a response advertises support for the QUERY method.

Type Aliases§

Result
A specialized Result for this crate.