pub struct HttpStatusDetails {
pub status: u16,
pub retry_after: Option<String>,
pub www_authenticate: Option<String>,
}Expand description
The HTTP status of a non-success response, with its Retry-After and
WWW-Authenticate headers if the server sent them.
The failed request reaches the caller as an Error::JsonRpc, and the
transport stays usable for the next request. The details ride in the
error’s data as {"httpStatus": 503, "retryAfter": "7"};
from_error reads them back, for a retry policy that
needs to tell a transient failure from a dead server, or an authorization
failure from an ordinary error.
Two cases carry them:
- A status with no JSON-RPC error body (a 429 from a rate limiter, a 502
or 503 from a gateway). The error has code
-32000. - A 401, 403 or 429 whose body is a JSON-RPC error. That error is the
server’s own, code and message included, with the status added to its
data(#1555): an existing objectdatakeeps its keys and gains the status keys where absent, and any otherdatamoves underserverData.
A 404 or 410 with no JSON-RPC body still closes the transport, since
either means the endpoint is gone; a 404 on a session request instead
recovers the session. Errors from the initial initialize request, which
is sent synchronously, are reported as Error::Transport text and carry
no details.
Fields§
§status: u16The HTTP status code of the response.
retry_after: Option<String>The raw Retry-After header value: delta-seconds ("7") or an
HTTP-date, passed through unparsed.
www_authenticate: Option<String>The raw WWW-Authenticate challenge, as sent with a 401 or a 403.
Several header lines are joined with , .
Implementations§
Source§impl HttpStatusDetails
impl HttpStatusDetails
Sourcepub fn from_error(error: &Error) -> Option<Self>
pub fn from_error(error: &Error) -> Option<Self>
Read the details from an error, if it came from a non-success HTTP status.
Sourcepub fn retry_after_delay(&self) -> Option<Duration>
pub fn retry_after_delay(&self) -> Option<Duration>
The Retry-After value as a delay, when it is delta-seconds. None
when absent or an HTTP-date.
Trait Implementations§
Source§impl Clone for HttpStatusDetails
impl Clone for HttpStatusDetails
Source§impl Debug for HttpStatusDetails
impl Debug for HttpStatusDetails
impl Eq for HttpStatusDetails
Source§impl PartialEq for HttpStatusDetails
impl PartialEq for HttpStatusDetails
impl StructuralPartialEq for HttpStatusDetails
Auto Trait Implementations§
impl Freeze for HttpStatusDetails
impl RefUnwindSafe for HttpStatusDetails
impl Send for HttpStatusDetails
impl Sync for HttpStatusDetails
impl Unpin for HttpStatusDetails
impl UnsafeUnpin for HttpStatusDetails
impl UnwindSafe for HttpStatusDetails
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.