Handle malformed HEADERS

This commit is contained in:
Carl Lerche
2017-08-25 13:00:42 -07:00
parent 9d45255c75
commit 14f35f1be6
12 changed files with 155 additions and 54 deletions

View File

@@ -26,6 +26,8 @@ use bytes::{Buf, IntoBuf};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_io::codec::length_delimited;
use std::io;
/// Either a Client or a Server
pub trait Peer {
/// Message type sent into the transport
@@ -50,6 +52,17 @@ pub type PingPayload = [u8; 8];
pub type WindowSize = u32;
/// Errors that are received
#[derive(Debug)]
pub enum ProtoError {
Connection(Reason),
Stream {
id: StreamId,
reason: Reason,
},
Io(io::Error),
}
// Constants
pub const DEFAULT_INITIAL_WINDOW_SIZE: WindowSize = 65_535;
pub const MAX_WINDOW_SIZE: WindowSize = (1 << 31) - 1;
@@ -88,3 +101,11 @@ pub(crate) fn from_framed_write<T, P, B>(framed_write: FramedWrite<T, Prioritize
Connection::new(codec)
}
// ===== impl ProtoError =====
impl From<io::Error> for ProtoError {
fn from(src: io::Error) -> Self {
ProtoError::Io(src)
}
}