add support for configuring max frame size
- Adds `max_frame_size` to client and server builders - Pushes max_frame_size into Codec - Detects when the Codec triggers an error from a frame too big - Sends a GOAWAY when FRAME_SIZE_ERROR is encountered reading a frame
This commit is contained in:
		| @@ -33,7 +33,7 @@ impl Reason { | ||||
|             FlowControlError => "flow-control protocol violated", | ||||
|             SettingsTimeout => "settings ACK not received in timely manner", | ||||
|             StreamClosed => "received frame when stream half-closed", | ||||
|             FrameSizeError => "frame sent with invalid size", | ||||
|             FrameSizeError => "frame with invalid size", | ||||
|             RefusedStream => "refused stream before processing any application logic", | ||||
|             Cancel => "stream no longer needed", | ||||
|             CompressionError => "unable to maintain the header compression context", | ||||
|   | ||||
| @@ -46,7 +46,7 @@ pub const DEFAULT_MAX_FRAME_SIZE: FrameSize = 16_384; | ||||
| pub const MAX_INITIAL_WINDOW_SIZE: usize = (1 << 31) - 1; | ||||
|  | ||||
| /// MAX_FRAME_SIZE upper bound | ||||
| pub const MAX_MAX_FRAME_SIZE: usize = (1 << 24) - 1; | ||||
| pub const MAX_MAX_FRAME_SIZE: FrameSize = (1 << 24) - 1; | ||||
|  | ||||
| // ===== impl Settings ===== | ||||
|  | ||||
| @@ -78,6 +78,13 @@ impl Settings { | ||||
|         self.max_frame_size | ||||
|     } | ||||
|  | ||||
|     pub fn set_max_frame_size(&mut self, size: Option<u32>) { | ||||
|         if let Some(val) = size { | ||||
|             assert!(DEFAULT_MAX_FRAME_SIZE <= val && val <= MAX_MAX_FRAME_SIZE); | ||||
|         } | ||||
|         self.max_frame_size = size; | ||||
|     } | ||||
|  | ||||
|     pub fn load(head: Head, payload: &[u8]) -> Result<Settings, Error> { | ||||
|         use self::Setting::*; | ||||
|  | ||||
| @@ -131,7 +138,7 @@ impl Settings { | ||||
|                     settings.initial_window_size = Some(val); | ||||
|                 }, | ||||
|                 Some(MaxFrameSize(val)) => { | ||||
|                     if val < DEFAULT_MAX_FRAME_SIZE || val as usize > MAX_MAX_FRAME_SIZE { | ||||
|                     if val < DEFAULT_MAX_FRAME_SIZE || val > MAX_MAX_FRAME_SIZE { | ||||
|                         return Err(Error::InvalidSettingValue); | ||||
|                     } else { | ||||
|                         settings.max_frame_size = Some(val); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user