Skip to content

Commit

Permalink
add HEADER_BYTES_LEN
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Oct 28, 2024
1 parent 2a01232 commit 7b0bc23
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client/response/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use gio::{
};
use glib::{Bytes, Priority};

pub const HEADER_BYTES_LEN: usize = 0x400; // 1024

pub struct Header {
status: Status,
meta: Option<Meta>,
Expand All @@ -34,7 +36,7 @@ impl Header {
) {
// Take header buffer from input stream
Self::read_from_socket_connection_async(
Vec::with_capacity(1024),
Vec::with_capacity(HEADER_BYTES_LEN),
socket_connection,
match cancellable {
Some(value) => Some(value),
Expand Down Expand Up @@ -105,7 +107,7 @@ impl Header {
move |result| match result {
Ok(bytes) => {
// Expect valid header length
if bytes.len() == 0 || buffer.len() + 1 > 1024 {
if bytes.len() == 0 || buffer.len() >= HEADER_BYTES_LEN {
return callback(Err((Error::Protocol, None)));
}

Expand Down

0 comments on commit 7b0bc23

Please sign in to comment.