Add http2_adaptive_window and htt2_max_frame_size from hyper (#1194)
Fixes #1193.
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							6ac97dc3aa
						
					
				
				
					commit
					ff2381e61e
				
			| @@ -103,6 +103,8 @@ struct Config { | |||||||
|     http1_title_case_headers: bool, |     http1_title_case_headers: bool, | ||||||
|     http2_initial_stream_window_size: Option<u32>, |     http2_initial_stream_window_size: Option<u32>, | ||||||
|     http2_initial_connection_window_size: Option<u32>, |     http2_initial_connection_window_size: Option<u32>, | ||||||
|  |     http2_adaptive_window: bool, | ||||||
|  |     http2_max_frame_size: Option<u32>, | ||||||
|     local_address: Option<IpAddr>, |     local_address: Option<IpAddr>, | ||||||
|     nodelay: bool, |     nodelay: bool, | ||||||
|     #[cfg(feature = "cookies")] |     #[cfg(feature = "cookies")] | ||||||
| @@ -159,6 +161,8 @@ impl ClientBuilder { | |||||||
|                 http1_title_case_headers: false, |                 http1_title_case_headers: false, | ||||||
|                 http2_initial_stream_window_size: None, |                 http2_initial_stream_window_size: None, | ||||||
|                 http2_initial_connection_window_size: None, |                 http2_initial_connection_window_size: None, | ||||||
|  |                 http2_adaptive_window: false, | ||||||
|  |                 http2_max_frame_size: None, | ||||||
|                 local_address: None, |                 local_address: None, | ||||||
|                 nodelay: true, |                 nodelay: true, | ||||||
|                 trust_dns: cfg!(feature = "trust-dns"), |                 trust_dns: cfg!(feature = "trust-dns"), | ||||||
| @@ -332,6 +336,12 @@ impl ClientBuilder { | |||||||
|         { |         { | ||||||
|             builder.http2_initial_connection_window_size(http2_initial_connection_window_size); |             builder.http2_initial_connection_window_size(http2_initial_connection_window_size); | ||||||
|         } |         } | ||||||
|  |         if config.http2_adaptive_window { | ||||||
|  |             builder.http2_adaptive_window(true); | ||||||
|  |         } | ||||||
|  |         if let Some(http2_max_frame_size) = config.http2_max_frame_size { | ||||||
|  |             builder.http2_max_frame_size(http2_max_frame_size); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         builder.pool_idle_timeout(config.pool_idle_timeout); |         builder.pool_idle_timeout(config.pool_idle_timeout); | ||||||
|         builder.pool_max_idle_per_host(config.pool_max_idle_per_host); |         builder.pool_max_idle_per_host(config.pool_max_idle_per_host); | ||||||
| @@ -680,6 +690,23 @@ impl ClientBuilder { | |||||||
|         self |         self | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Sets whether to use an adaptive flow control. | ||||||
|  |     /// | ||||||
|  |     /// Enabling this will override the limits set in `http2_initial_stream_window_size` and | ||||||
|  |     /// `http2_initial_connection_window_size`. | ||||||
|  |     pub fn http2_adaptive_window(mut self, enabled: bool) -> ClientBuilder { | ||||||
|  |         self.config.http2_adaptive_window = enabled; | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Sets the maximum frame size to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Default is currently 16,384 but may change internally to optimize for common uses. | ||||||
|  |     pub fn http2_max_frame_size(mut self, sz: impl Into<Option<u32>>) -> ClientBuilder { | ||||||
|  |         self.config.http2_max_frame_size = sz.into(); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // TCP options |     // TCP options | ||||||
|  |  | ||||||
|     /// Set whether sockets have `SO_NODELAY` enabled. |     /// Set whether sockets have `SO_NODELAY` enabled. | ||||||
|   | |||||||
| @@ -374,6 +374,21 @@ impl ClientBuilder { | |||||||
|         self.with_inner(|inner| inner.http2_initial_connection_window_size(sz)) |         self.with_inner(|inner| inner.http2_initial_connection_window_size(sz)) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Sets whether to use an adaptive flow control. | ||||||
|  |     /// | ||||||
|  |     /// Enabling this will override the limits set in `http2_initial_stream_window_size` and | ||||||
|  |     /// `http2_initial_connection_window_size`. | ||||||
|  |     pub fn http2_adaptive_window(self, enabled: bool) -> ClientBuilder { | ||||||
|  |         self.with_inner(|inner| inner.http2_adaptive_window(enabled)) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Sets the maximum frame size to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Default is currently 16,384 but may change internally to optimize for common uses. | ||||||
|  |     pub fn http2_max_frame_size(self, sz: impl Into<Option<u32>>) -> ClientBuilder { | ||||||
|  |         self.with_inner(|inner| inner.http2_max_frame_size(sz)) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // TCP options |     // TCP options | ||||||
|  |  | ||||||
|     /// Set whether sockets have `SO_NODELAY` enabled. |     /// Set whether sockets have `SO_NODELAY` enabled. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user