update meta parser

This commit is contained in:
yggverse 2024-10-30 14:22:08 +02:00
parent 8c1afd654a
commit 36b8342f29

View file

@ -5,6 +5,8 @@ use glib::GString;
/// Response meta holder /// Response meta holder
/// ///
/// Could be created from entire response buffer or just header slice
///
/// Use as: /// Use as:
/// * placeholder for 10, 11 status /// * placeholder for 10, 11 status
/// * URL for 30, 31 status /// * URL for 30, 31 status
@ -18,22 +20,16 @@ impl Meta {
// Init bytes buffer // Init bytes buffer
let mut bytes: Vec<u8> = Vec::new(); let mut bytes: Vec<u8> = Vec::new();
// Skip status code // Skip 3 bytes for status code of 1024 expected
match buffer.get(3..) { match buffer.get(3..1021) {
Some(slice) => { Some(slice) => {
for (count, &byte) in slice.iter().enumerate() { for &byte in slice {
// Validate length // End of header
if count > 0x400 {
// 1024
return Err(Error::Protocol);
}
// End of line, done
if byte == b'\r' { if byte == b'\r' {
break; break;
} }
// Append // Continue
bytes.push(byte); bytes.push(byte);
} }