Struct hyper::ext::ReasonPhrase
source · pub struct ReasonPhrase(/* private fields */);
Expand description
A reason phrase in an HTTP/1 response.
§Clients
For clients, a ReasonPhrase
will be present in the extensions of the http::Response
returned
for a request if the reason phrase is different from the canonical reason phrase for the
response’s status code. For example, if a server returns HTTP/1.1 200 Awesome
, the
ReasonPhrase
will be present and contain Awesome
, but if a server returns HTTP/1.1 200 OK
,
the response will not contain a ReasonPhrase
.
use hyper::{Client, Uri};
use hyper::ext::ReasonPhrase;
let res = Client::new().get(Uri::from_static("http://example.com/non_canonical_reason")).await?;
// Print out the non-canonical reason phrase, if it has one...
if let Some(reason) = res.extensions().get::<ReasonPhrase>() {
println!("non-canonical reason: {}", std::str::from_utf8(reason.as_bytes()).unwrap());
}
§Servers
When a ReasonPhrase
is present in the extensions of the http::Response
written by a server,
its contents will be written in place of the canonical reason phrase when responding via HTTP/1.
Implementations§
source§impl ReasonPhrase
impl ReasonPhrase
Trait Implementations§
source§impl AsRef<[u8]> for ReasonPhrase
impl AsRef<[u8]> for ReasonPhrase
source§impl Clone for ReasonPhrase
impl Clone for ReasonPhrase
source§fn clone(&self) -> ReasonPhrase
fn clone(&self) -> ReasonPhrase
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ReasonPhrase
impl Debug for ReasonPhrase
source§impl From<ReasonPhrase> for Bytes
impl From<ReasonPhrase> for Bytes
source§fn from(reason: ReasonPhrase) -> Self
fn from(reason: ReasonPhrase) -> Self
Converts to this type from the input type.
source§impl Hash for ReasonPhrase
impl Hash for ReasonPhrase
source§impl Ord for ReasonPhrase
impl Ord for ReasonPhrase
source§fn cmp(&self, other: &ReasonPhrase) -> Ordering
fn cmp(&self, other: &ReasonPhrase) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for ReasonPhrase
impl PartialEq for ReasonPhrase
source§impl PartialOrd for ReasonPhrase
impl PartialOrd for ReasonPhrase
source§impl TryFrom<&[u8]> for ReasonPhrase
impl TryFrom<&[u8]> for ReasonPhrase
source§impl TryFrom<Bytes> for ReasonPhrase
impl TryFrom<Bytes> for ReasonPhrase
source§impl TryFrom<String> for ReasonPhrase
impl TryFrom<String> for ReasonPhrase
impl Eq for ReasonPhrase
impl StructuralPartialEq for ReasonPhrase
Auto Trait Implementations§
impl !Freeze for ReasonPhrase
impl RefUnwindSafe for ReasonPhrase
impl Send for ReasonPhrase
impl Sync for ReasonPhrase
impl Unpin for ReasonPhrase
impl UnwindSafe for ReasonPhrase
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
key
and return true
if they are equal.