Validate & convert messages before buffering

Malformed requests and responses should immediately result in a
RST_STREAM. To support this, received header frames are validated and
converted to Request / Response values immediately on receipt and before
buffering.
This commit is contained in:
Carl Lerche
2017-08-30 18:00:32 -04:00
parent 9bb34d907a
commit 2452cc4423
10 changed files with 246 additions and 157 deletions

View File

@@ -26,7 +26,7 @@ use bytes::{Buf, IntoBuf};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_io::codec::length_delimited;
use std::io;
use std::{fmt, io};
/// Either a Client or a Server
pub trait Peer {
@@ -34,7 +34,7 @@ pub trait Peer {
type Send;
/// Message type polled from the transport
type Poll;
type Poll: fmt::Debug;
fn is_server() -> bool;
@@ -43,7 +43,7 @@ pub trait Peer {
headers: Self::Send,
end_of_stream: bool) -> frame::Headers;
fn convert_poll_message(headers: frame::Headers) -> Result<Self::Poll, ConnectionError>;
fn convert_poll_message(headers: frame::Headers) -> Result<Self::Poll, ProtoError>;
}
pub type PingPayload = [u8; 8];