Trait reqwest::header::Header
[−]
[src]
pub trait Header: 'static + HeaderClone + Send + Sync {
fn header_name() -> &'static str;
fn parse_header(raw: &Raw) -> Result<Self, Error>;
fn fmt_header(&self, f: &mut Formatter) -> Result<(), Error>;
}A trait for any object that will represent a header field and value.
This trait represents the construction and identification of headers, and contains trait-object unsafe methods.
Required Methods
fn header_name() -> &'static str
Returns the name of the header field this belongs to.
This will become an associated constant once available.
fn parse_header(raw: &Raw) -> Result<Self, Error>
Parse a header from a raw stream of bytes.
It's possible that a request can include a header field more than once,
and in that case, the slice will have a length greater than 1. However,
it's not necessarily the case that a Header is allowed to have more
than one field value. If that's the case, you should return None
if raw.len() > 1.
fn fmt_header(&self, f: &mut Formatter) -> Result<(), Error>
Format a header to outgoing stream.
Most headers should be formatted on one line, and so a common pattern
would be to implement std::fmt::Display for this type as well, and
then just call f.fmt_line(self).
Note
This has the ability to format a header over multiple lines.
The main example here is Set-Cookie, which requires that every
cookie being set be specified in a separate line. Almost every other
case should only format as 1 single line.
Implementors
impl Header for PreferenceAppliedimpl Header for IfModifiedSinceimpl Header for AcceptCharsetimpl Header for ContentLengthimpl Header for AcceptEncodingimpl Header for Originimpl Header for Teimpl Header for Dateimpl Header for Connectionimpl Header for AccessControlRequestHeadersimpl Header for AccessControlMaxAgeimpl Header for LastEventIdimpl Header for ContentEncodingimpl Header for ContentLanguageimpl Header for Hostimpl Header for Expectimpl Header for ContentLocationimpl Header for AcceptLanguageimpl Header for Refererimpl Header for Preferimpl Header for AccessControlRequestMethodimpl Header for ReferrerPolicyimpl Header for SetCookieimpl<S> Header for Authorization<S> where
S: Scheme + Any,
<S as FromStr>::Err: 'static,impl Header for TransferEncodingimpl Header for ContentDispositionimpl Header for Serverimpl<S> Header for ProxyAuthorization<S> where
S: Scheme + Any,
<S as FromStr>::Err: 'static,impl Header for LastModifiedimpl Header for Locationimpl Header for IfUnmodifiedSinceimpl Header for CacheControlimpl Header for IfMatchimpl Header for AccessControlAllowOriginimpl Header for Expiresimpl Header for AcceptRangesimpl Header for Upgradeimpl Header for ContentTypeimpl Header for AccessControlExposeHeadersimpl Header for Warningimpl Header for RetryAfterimpl Header for AccessControlAllowMethodsimpl Header for Varyimpl Header for ETagimpl Header for ContentRangeimpl Header for UserAgentimpl Header for Pragmaimpl Header for Linkimpl Header for Allowimpl Header for AccessControlAllowHeadersimpl Header for IfRangeimpl Header for Cookieimpl Header for AccessControlAllowCredentialsimpl Header for Acceptimpl Header for IfNoneMatchimpl Header for StrictTransportSecurityimpl Header for Rangeimpl Header for From