Memory exhaustion (#69)

This commit is contained in:
ssrlive 2023-10-10 14:22:33 +08:00 committed by GitHub
parent 299b51667d
commit b50cac82c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 23 deletions

View file

@ -366,15 +366,15 @@ impl ProxyHandler for HttpConnection {
self.state == HttpState::Established
}
fn have_data(&mut self, dir: Direction) -> bool {
fn data_len(&self, dir: Direction) -> usize {
match dir {
Direction::Incoming(incoming) => match incoming {
IncomingDirection::FromServer => !self.server_inbuf.is_empty(),
IncomingDirection::FromClient => !self.client_inbuf.is_empty() || !self.data_buf.is_empty(),
IncomingDirection::FromServer => self.server_inbuf.len(),
IncomingDirection::FromClient => self.client_inbuf.len().max(self.data_buf.len()),
},
Direction::Outgoing(outgoing) => match outgoing {
OutgoingDirection::ToServer => !self.server_outbuf.is_empty(),
OutgoingDirection::ToClient => !self.client_outbuf.is_empty(),
OutgoingDirection::ToServer => self.server_outbuf.len(),
OutgoingDirection::ToClient => self.client_outbuf.len(),
},
}
}