http2: set Debug on structs

pull/6197/head
Victor Julien 5 years ago
parent 86e600dab8
commit 20e8f90981

@ -34,6 +34,7 @@ pub enum HTTP2ContentEncoding {
} }
//a cursor turning EOF into blocking errors //a cursor turning EOF into blocking errors
#[derive(Debug)]
pub struct HTTP2cursor { pub struct HTTP2cursor {
pub cursor: Cursor<Vec<u8>>, pub cursor: Cursor<Vec<u8>>,
} }
@ -78,6 +79,26 @@ pub enum HTTP2Decompresser {
BROTLI(brotli::Decompressor<HTTP2cursor>), BROTLI(brotli::Decompressor<HTTP2cursor>),
} }
impl std::fmt::Debug for HTTP2Decompresser {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
HTTP2Decompresser::UNASSIGNED => write!(f, "UNASSIGNED"),
HTTP2Decompresser::GZIP(_) => write!(f, "GZIP"),
HTTP2Decompresser::BROTLI(_) => write!(f, "BROTLI"),
}
}
}
impl std::fmt::Display for HTTP2Decompresser {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
HTTP2Decompresser::UNASSIGNED => write!(f, "UNASSIGNED"),
HTTP2Decompresser::GZIP(_) => write!(f, "GZIP"),
HTTP2Decompresser::BROTLI(_) => write!(f, "BROTLI"),
}
}
}
#[derive(Debug)]
struct HTTP2DecoderHalf { struct HTTP2DecoderHalf {
encoding: HTTP2ContentEncoding, encoding: HTTP2ContentEncoding,
decoder: HTTP2Decompresser, decoder: HTTP2Decompresser,
@ -192,6 +213,7 @@ impl HTTP2DecoderHalf {
} }
} }
#[derive(Debug)]
pub struct HTTP2Decoder { pub struct HTTP2Decoder {
decoder_tc: HTTP2DecoderHalf, decoder_tc: HTTP2DecoderHalf,
decoder_ts: HTTP2DecoderHalf, decoder_ts: HTTP2DecoderHalf,

@ -82,6 +82,7 @@ pub struct HTTP2FrameUnhandled {
pub reason: HTTP2FrameUnhandledReason, pub reason: HTTP2FrameUnhandledReason,
} }
#[derive(Debug)]
pub enum HTTP2FrameTypeData { pub enum HTTP2FrameTypeData {
PRIORITY(parser::HTTP2FramePriority), PRIORITY(parser::HTTP2FramePriority),
GOAWAY(parser::HTTP2FrameGoAway), GOAWAY(parser::HTTP2FrameGoAway),
@ -112,11 +113,13 @@ pub enum HTTP2TransactionState {
HTTP2StateGlobal = 8, HTTP2StateGlobal = 8,
} }
#[derive(Debug)]
pub struct HTTP2Frame { pub struct HTTP2Frame {
pub header: parser::HTTP2FrameHeader, pub header: parser::HTTP2FrameHeader,
pub data: HTTP2FrameTypeData, pub data: HTTP2FrameTypeData,
} }
#[derive(Debug)]
pub struct HTTP2Transaction { pub struct HTTP2Transaction {
tx_id: u64, tx_id: u64,
pub stream_id: u32, pub stream_id: u32,

@ -21,7 +21,7 @@ use crate::jsonbuilder::{JsonBuilder, JsonError};
use std; use std;
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Hash, PartialEq, Eq)] #[derive(Hash, PartialEq, Eq, Debug)]
enum HeaderName { enum HeaderName {
Method, Method,
Path, Path,

@ -69,7 +69,7 @@ impl std::str::FromStr for HTTP2FrameType {
} }
} }
#[derive(PartialEq)] #[derive(PartialEq, Debug)]
pub struct HTTP2FrameHeader { pub struct HTTP2FrameHeader {
//we could add detection on (GOAWAY) additional data //we could add detection on (GOAWAY) additional data
pub length: u32, pub length: u32,
@ -142,7 +142,7 @@ impl std::str::FromStr for HTTP2ErrorCode {
} }
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct HTTP2FrameGoAway { pub struct HTTP2FrameGoAway {
pub errorcode: u32, //HTTP2ErrorCode pub errorcode: u32, //HTTP2ErrorCode
} }
@ -154,7 +154,7 @@ named!(pub http2_parse_frame_goaway<HTTP2FrameGoAway>,
) )
); );
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct HTTP2FrameRstStream { pub struct HTTP2FrameRstStream {
pub errorcode: u32, ////HTTP2ErrorCode pub errorcode: u32, ////HTTP2ErrorCode
} }
@ -166,7 +166,7 @@ named!(pub http2_parse_frame_rststream<HTTP2FrameRstStream>,
) )
); );
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct HTTP2FramePriority { pub struct HTTP2FramePriority {
pub exclusive: u8, pub exclusive: u8,
pub dependency: u32, pub dependency: u32,
@ -182,7 +182,7 @@ named!(pub http2_parse_frame_priority<HTTP2FramePriority>,
) )
); );
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct HTTP2FrameWindowUpdate { pub struct HTTP2FrameWindowUpdate {
pub reserved: u8, pub reserved: u8,
pub sizeinc: u32, pub sizeinc: u32,
@ -196,7 +196,7 @@ named!(pub http2_parse_frame_windowupdate<HTTP2FrameWindowUpdate>,
) )
); );
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct HTTP2FrameHeadersPriority { pub struct HTTP2FrameHeadersPriority {
pub exclusive: u8, pub exclusive: u8,
pub dependency: u32, pub dependency: u32,
@ -600,7 +600,7 @@ fn http2_parse_headers_block<'a>(
} }
} }
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct HTTP2FrameHeaders { pub struct HTTP2FrameHeaders {
pub padlength: Option<u8>, pub padlength: Option<u8>,
pub priority: Option<HTTP2FrameHeadersPriority>, pub priority: Option<HTTP2FrameHeadersPriority>,
@ -649,7 +649,7 @@ pub fn http2_parse_frame_headers<'a>(
)); ));
} }
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct HTTP2FramePushPromise { pub struct HTTP2FramePushPromise {
pub padlength: Option<u8>, pub padlength: Option<u8>,
pub reserved: u8, pub reserved: u8,
@ -690,7 +690,7 @@ pub fn http2_parse_frame_push_promise<'a>(
)); ));
} }
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct HTTP2FrameContinuation { pub struct HTTP2FrameContinuation {
pub blocks: Vec<HTTP2FrameHeaderBlock>, pub blocks: Vec<HTTP2FrameHeaderBlock>,
} }
@ -898,7 +898,7 @@ named!(pub detect_parse_u64<&str,DetectU64Data>,
) )
); );
#[derive(Clone, Copy)] #[derive(Clone, Copy, Debug)]
pub struct HTTP2FrameSettings { pub struct HTTP2FrameSettings {
pub id: HTTP2SettingsId, pub id: HTTP2SettingsId,
pub value: u32, pub value: u32,

Loading…
Cancel
Save