pub struct RawHead<'a> { /* private fields */ }Expand description
The bytes of a head and the spans of its parts, all relative to
bytes: what RequestHead::raw and
ResponseHead::raw return.
The bytes run from the first byte the connection kept for the message
(any empty lines a client sent before the request line, which RFC 9112
section 2.2 lets a server skip, are included) to the end of the blank
line that ends the head. Spans for parts a head does not have are empty:
status on a request, method and target on a response.
Debug shows lengths and spans only, never the bytes, so a raw head in
a log cannot leak a credential.
§Examples
use http_net::{ServerConn, ServerEvent};
let mut conn = ServerConn::new();
let _ = conn.feed(b"GET /a HTTP/1.1\r\nHost: x\r\n\r\nbody bytes are not part of it");
let ServerEvent::Request(req) = conn.poll().unwrap() else { panic!() };
let raw = req.raw();
assert_eq!(raw.bytes(), b"GET /a HTTP/1.1\r\nHost: x\r\n\r\n");
assert_eq!(raw.method().get(raw.bytes()), b"GET");
assert_eq!(raw.target().get(raw.bytes()), b"/a");
assert_eq!(raw.version().get(raw.bytes()), b"HTTP/1.1");
assert!(raw.status().is_empty());
assert_eq!(raw.fields().len(), 1);Implementations§
Source§impl<'a> RawHead<'a>
impl<'a> RawHead<'a>
Sourcepub fn start_line(&self) -> Span
pub fn start_line(&self) -> Span
The request line or status line, without its CRLF.
§Examples
let raw = req.raw();
assert_eq!(raw.start_line().get(raw.bytes()), b"GET / HTTP/1.1");Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RawHead<'a>
impl<'a> RefUnwindSafe for RawHead<'a>
impl<'a> Send for RawHead<'a>
impl<'a> Sync for RawHead<'a>
impl<'a> Unpin for RawHead<'a>
impl<'a> UnsafeUnpin for RawHead<'a>
impl<'a> UnwindSafe for RawHead<'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