pub struct Header { /* private fields */ }Expand description
A HTTP header
Implementations§
source§impl Header
impl Header
sourcepub const fn new(start_line: HeaderStartLine, fields: HeaderFields) -> Self
pub const fn new(start_line: HeaderStartLine, fields: HeaderFields) -> Self
Creates a new HTTP/1.1 header
sourcepub fn start_line(&self) -> &HeaderStartLine
pub fn start_line(&self) -> &HeaderStartLine
The start line
sourcepub fn start_line_mut(&mut self) -> &mut HeaderStartLine
pub fn start_line_mut(&mut self) -> &mut HeaderStartLine
The start line
sourcepub fn fields(&self) -> &HeaderFields
pub fn fields(&self) -> &HeaderFields
The header fields
sourcepub fn fields_mut(&mut self) -> &mut HeaderFields
pub fn fields_mut(&mut self) -> &mut HeaderFields
The header fields
sourcepub fn read<T>(source: &mut T) -> Result<Self, Error>where
T: BufRead,
pub fn read<T>(source: &mut T) -> Result<Self, Error>where
T: BufRead,
Loads a HTTP header from bytes and returns the remaining bytes
§Warning:
This function will read forever until there is either a \r\n\r\n or an EOF. To prevent DOS-attacks, it is
strongly recommended to wrap the source into a std::io::Take to limit the amount of data that will be read.
Trait Implementations§
source§impl Ord for Header
impl Ord for Header
source§impl PartialEq for Header
impl PartialEq for Header
source§impl PartialOrd for Header
impl PartialOrd for Header
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl RequestBuilder for Header
impl RequestBuilder for Header
source§fn new_request<M, T>(method: M, target: T) -> Self
fn new_request<M, T>(method: M, target: T) -> Self
Creates a new request
source§fn set_header<K, V>(self, key: K, value: V) -> Self
fn set_header<K, V>(self, key: K, value: V) -> Self
Sets an arbitrary header key-value pair
source§fn set_content_length<T>(self, length: T) -> Selfwhere
T: IntoBytes,
fn set_content_length<T>(self, length: T) -> Selfwhere
T: IntoBytes,
Sets the “Content-Length” header for
selfsource§impl RequestHeader for Header
impl RequestHeader for Header
source§impl ResponseBuilder for Header
impl ResponseBuilder for Header
source§fn new_response<S, R>(status: S, reason: R) -> Self
fn new_response<S, R>(status: S, reason: R) -> Self
Creates a new response
source§fn set_header<K, V>(self, key: K, value: V) -> Self
fn set_header<K, V>(self, key: K, value: V) -> Self
Sets an arbitrary header key-value pair
source§fn set_content_type<T>(self, type_: T) -> Selfwhere
T: IntoBytes,
fn set_content_type<T>(self, type_: T) -> Selfwhere
T: IntoBytes,
Sets the status/reason tuple for
selfsource§fn set_content_length<T>(self, length: T) -> Selfwhere
T: IntoBytes,
fn set_content_length<T>(self, length: T) -> Selfwhere
T: IntoBytes,
Sets the “Content-Length” header for
selfsource§impl ResponseHeader for Header
impl ResponseHeader for Header
impl Eq for Header
impl StructuralEq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
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