mirror of
https://github.com/telemt/telemt.git
synced 2026-11-22 15:26:37 +03:00
Restart-gated Decoy Fast-Track
Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/// Splits one complete raw HTTP response into head and body slices.
|
||||
pub(in crate::web::http) fn split_response(response: &[u8]) -> (&[u8], &[u8]) {
|
||||
let separator = response
|
||||
.windows(4)
|
||||
.position(|window| window == b"\r\n\r\n")
|
||||
.unwrap();
|
||||
(&response[..separator], &response[separator + 4..])
|
||||
}
|
||||
|
||||
/// Returns one case-insensitive header value from a raw HTTP response head.
|
||||
pub(in crate::web::http) fn response_header<'a>(headers: &'a [u8], name: &str) -> &'a str {
|
||||
std::str::from_utf8(headers)
|
||||
.unwrap()
|
||||
.lines()
|
||||
.filter_map(|line| line.split_once(':'))
|
||||
.find_map(|(header, value)| header.eq_ignore_ascii_case(name).then_some(value.trim()))
|
||||
.unwrap()
|
||||
}
|
||||
Reference in New Issue
Block a user