Struct web_socket::http::Http
source · pub struct Http<'a> {
pub schema: &'a [u8],
pub headers: HashMap<String, &'a [u8]>,
}Expand description
it represents an HTTP message with a schema and a header.
Example
let mut bytes = "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n".as_bytes();
let header = web_socket::http::Http::parse(&mut bytes).unwrap();
assert_eq!(header.schema, "HTTP/1.1 101 Switching Protocols".as_bytes());
assert_eq!(header.get("upgrade"), Some("websocket".as_bytes()));
assert_eq!(
header.get_sec_ws_accept(),
Some("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=".as_bytes())
);Fields§
§schema: &'a [u8]schema of the http message (e.g. HTTP/1.1 101 Switching Protocols)
headers: HashMap<String, &'a [u8]>key-value pairs of http headers