pub struct Message {
pub body: BodyContentType,
pub headers: HashMap<String, HeaderValueParts>,
pub request_line: Line,
}Fields§
§body: BodyContentType§headers: HashMap<String, HeaderValueParts>§request_line: LineImplementations§
Source§impl Message
impl Message
pub fn get_protocol_text(protocol: &Protocol) -> String
pub fn get_message_body(body: &str) -> Option<BodyContentType>
pub fn get_header_field(line: &str) -> Option<(String, HeaderValueParts)>
pub fn get_request_line(line: &str) -> Option<Line>
Sourcepub fn from_tcp_stream(request: &[u8]) -> Option<Message>
pub fn from_tcp_stream(request: &[u8]) -> Option<Message>
Try to decode a byte stream into a HTTP Message
§Usage
use milstian_http::request::{Message, Method, Protocol};
let response = Message::from_tcp_stream(b"GET / HTTP/2.0\r\n");
let response_unwrapped = response.expect("A decoded HTTP Message");
assert_eq!(response_unwrapped.request_line.method, Method::Get);
assert_eq!(response_unwrapped.request_line.request_uri, "/".to_string());
assert_eq!(response_unwrapped.request_line.protocol, Protocol::V2_0);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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