pub struct Headers { /* private fields */ }Expand description
HTTP message headers (or trailers)
Implementations§
Source§impl Headers
impl Headers
Sourcepub fn from_vec(headers: Vec<Header>) -> Headers
pub fn from_vec(headers: Vec<Header>) -> Headers
Construct headers from a vec of individual headers
Sourcepub fn iter(&self) -> impl Iterator<Item = &Header>
pub fn iter(&self) -> impl Iterator<Item = &Header>
Return an iterator over headers.
Pseudo headers returned first.
Sourcepub fn new_get(path: impl Into<HeaderValue>) -> Headers
pub fn new_get(path: impl Into<HeaderValue>) -> Headers
Construct a Headers object with specified :method and :path headers
Sourcepub fn new_post(path: impl Into<HeaderValue>) -> Headers
pub fn new_post(path: impl Into<HeaderValue>) -> Headers
Construct a Headers object with specified :method and :path headers
Sourcepub fn new_status(code: u32) -> Headers
pub fn new_status(code: u32) -> Headers
Construct a Headers object with single :status header
Sourcepub fn not_found_404() -> Headers
pub fn not_found_404() -> Headers
Construct :status 404 headers
Sourcepub fn internal_error_500() -> Headers
pub fn internal_error_500() -> Headers
Construct :status 500 headers
Sourcepub fn redirect_302(location: impl Into<HeaderValue>) -> Headers
pub fn redirect_302(location: impl Into<HeaderValue>) -> Headers
Construct :status 302; location: <location> headers
Sourcepub fn get_opt_parse<I: FromStr>(&self, name: &str) -> Option<I>
pub fn get_opt_parse<I: FromStr>(&self, name: &str) -> Option<I>
Lookup header.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Content-length header.
Sourcepub fn add(
&mut self,
name: impl Into<HeaderName>,
value: impl Into<HeaderValue>,
)
pub fn add( &mut self, name: impl Into<HeaderName>, value: impl Into<HeaderValue>, )
Add a header
Sourcepub fn add_header(&mut self, header: Header)
pub fn add_header(&mut self, header: Header)
Add a header
Trait Implementations§
Source§impl FromIterator<Header> for Headers
impl FromIterator<Header> for Headers
impl Eq for Headers
impl StructuralPartialEq for Headers
Auto Trait Implementations§
impl Freeze for Headers
impl RefUnwindSafe for Headers
impl Send for Headers
impl Sync for Headers
impl Unpin for Headers
impl UnsafeUnpin for Headers
impl UnwindSafe for Headers
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