mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
update meta parser
This commit is contained in:
parent
8c1afd654a
commit
36b8342f29
1 changed files with 7 additions and 11 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue