pub struct Response<'a> {
pub status: u16,
pub reason: &'a str,
pub version: u8,
/* private fields */
}Expand description
A parsed HTTP/1.x response. Borrows from the reader’s buffer.
Fields§
§status: u16HTTP status code (e.g., 101, 200, 404).
reason: &'a strReason phrase (e.g., “Switching Protocols”, “OK”).
version: u8HTTP version (0 = HTTP/1.0, 1 = HTTP/1.1).
Implementations§
Source§impl<'a> Response<'a>
impl<'a> Response<'a>
Sourcepub fn header(&self, name: &str) -> Option<&'a str>
pub fn header(&self, name: &str) -> Option<&'a str>
Look up a header value by name (case-insensitive).
Returns None if the header is not found or if the value is not valid UTF-8.
Use header_bytes for raw access to non-UTF-8 values.
Sourcepub fn header_bytes(&self, name: &str) -> Option<&'a [u8]>
pub fn header_bytes(&self, name: &str) -> Option<&'a [u8]>
Look up a raw header value by name (case-insensitive).
Returns the value as raw bytes without UTF-8 validation.
Sourcepub fn headers(&self) -> impl Iterator<Item = (&'a str, &'a str)>
pub fn headers(&self) -> impl Iterator<Item = (&'a str, &'a str)>
Iterate over headers as (name, value) pairs.
Skips headers with non-UTF-8 names or values.
Use header_count for the total count including non-UTF-8.
Sourcepub fn header_count(&self) -> usize
pub fn header_count(&self) -> usize
Number of parsed headers (including non-UTF-8).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Response<'a>
impl<'a> RefUnwindSafe for Response<'a>
impl<'a> Send for Response<'a>
impl<'a> Sync for Response<'a>
impl<'a> Unpin for Response<'a>
impl<'a> UnsafeUnpin for Response<'a>
impl<'a> UnwindSafe for Response<'a>
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