Compare commits
	
		
			2 Commits
		
	
	
		
			53f15e5870
			...
			v0.14.18-p
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | abf28d875e | ||
|  | db6c602667 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +1,3 @@ | |||||||
| target | target | ||||||
| Cargo.lock | Cargo.lock | ||||||
|  | .history | ||||||
| @@ -18,7 +18,10 @@ use super::pool::{ | |||||||
| #[cfg(feature = "tcp")] | #[cfg(feature = "tcp")] | ||||||
| use super::HttpConnector; | use super::HttpConnector; | ||||||
| use crate::body::{Body, HttpBody}; | use crate::body::{Body, HttpBody}; | ||||||
| use crate::common::{exec::BoxSendFuture, sync_wrapper::SyncWrapper, lazy as hyper_lazy, task, Future, Lazy, Pin, Poll}; | use crate::common::{ | ||||||
|  |     exec::BoxSendFuture, lazy as hyper_lazy, sync_wrapper::SyncWrapper, task, Future, Lazy, Pin, | ||||||
|  |     Poll, | ||||||
|  | }; | ||||||
| use crate::rt::Executor; | use crate::rt::Executor; | ||||||
|  |  | ||||||
| /// A Client to make outgoing HTTP requests. | /// A Client to make outgoing HTTP requests. | ||||||
| @@ -586,7 +589,7 @@ impl ResponseFuture { | |||||||
|         F: Future<Output = crate::Result<Response<Body>>> + Send + 'static, |         F: Future<Output = crate::Result<Response<Body>>> + Send + 'static, | ||||||
|     { |     { | ||||||
|         Self { |         Self { | ||||||
|             inner: SyncWrapper::new(Box::pin(value)) |             inner: SyncWrapper::new(Box::pin(value)), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -1181,8 +1184,6 @@ impl Builder { | |||||||
|     /// Sets the maximum frame size to use for HTTP2. |     /// Sets the maximum frame size to use for HTTP2. | ||||||
|     /// |     /// | ||||||
|     /// Passing `None` will do nothing. |     /// Passing `None` will do nothing. | ||||||
|     /// |  | ||||||
|     /// If not set, hyper will use a default. |  | ||||||
|     #[cfg(feature = "http2")] |     #[cfg(feature = "http2")] | ||||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|     pub fn http2_max_frame_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { |     pub fn http2_max_frame_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { | ||||||
| @@ -1278,6 +1279,46 @@ impl Builder { | |||||||
|         self |         self | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Sets the maximum concurrent streams to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing.. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_max_concurrent_streams(&mut self, max: u32) -> &mut Self { | ||||||
|  |         self.conn_builder.http2_max_concurrent_streams(max); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Sets the max header list size to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_max_header_list_size(&mut self, max: u32) -> &mut Self { | ||||||
|  |         self.conn_builder.http2_max_header_list_size(max); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Enables and disables the push feature for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_enable_push(&mut self, opt: bool) -> &mut Self { | ||||||
|  |         self.conn_builder.http2_enable_push(opt); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Sets the max header list size to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_header_table_size(&mut self, max: u32) -> &mut Self { | ||||||
|  |         self.conn_builder.http2_header_table_size(max); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /// Set whether to retry requests that get disrupted before ever starting |     /// Set whether to retry requests that get disrupted before ever starting | ||||||
|     /// to write. |     /// to write. | ||||||
|     /// |     /// | ||||||
|   | |||||||
| @@ -812,14 +812,10 @@ impl Builder { | |||||||
|     /// Sets the maximum frame size to use for HTTP2. |     /// Sets the maximum frame size to use for HTTP2. | ||||||
|     /// |     /// | ||||||
|     /// Passing `None` will do nothing. |     /// Passing `None` will do nothing. | ||||||
|     /// |  | ||||||
|     /// If not set, hyper will use a default. |  | ||||||
|     #[cfg(feature = "http2")] |     #[cfg(feature = "http2")] | ||||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|     pub fn http2_max_frame_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { |     pub fn http2_max_frame_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { | ||||||
|         if let Some(sz) = sz.into() { |         self.h2_builder.max_frame_size = sz.into(); | ||||||
|             self.h2_builder.max_frame_size = sz; |  | ||||||
|         } |  | ||||||
|         self |         self | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -912,6 +908,46 @@ impl Builder { | |||||||
|         self |         self | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Sets the maximum concurrent streams to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_max_concurrent_streams(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { | ||||||
|  |         self.h2_builder.max_concurrent_streams = sz.into(); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Sets the max header list size to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_max_header_list_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { | ||||||
|  |         self.h2_builder.max_header_list_size = sz.into(); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Enables and disables the push feature for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_enable_push(&mut self, sz: impl Into<Option<bool>>) -> &mut Self { | ||||||
|  |         self.h2_builder.enable_push = sz.into(); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /// Sets the header table size to use for HTTP2. | ||||||
|  |     /// | ||||||
|  |     /// Passing `None` will do nothing. | ||||||
|  |     #[cfg(feature = "http2")] | ||||||
|  |     #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] | ||||||
|  |     pub fn http2_header_table_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self { | ||||||
|  |         self.h2_builder.header_table_size = sz.into(); | ||||||
|  |         self | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /// Constructs a connection with the configured options and IO. |     /// Constructs a connection with the configured options and IO. | ||||||
|     /// See [`client::conn`](crate::client::conn) for more. |     /// See [`client::conn`](crate::client::conn) for more. | ||||||
|     /// |     /// | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ type ConnEof = oneshot::Receiver<Never>; | |||||||
| // for performance. | // for performance. | ||||||
| const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024 * 5; // 5mb | const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024 * 5; // 5mb | ||||||
| const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb | const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb | ||||||
| const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb | // const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb | ||||||
| const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 1024; // 1mb | const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 1024; // 1mb | ||||||
|  |  | ||||||
| #[derive(Clone, Debug)] | #[derive(Clone, Debug)] | ||||||
| @@ -44,7 +44,7 @@ pub(crate) struct Config { | |||||||
|     pub(crate) adaptive_window: bool, |     pub(crate) adaptive_window: bool, | ||||||
|     pub(crate) initial_conn_window_size: u32, |     pub(crate) initial_conn_window_size: u32, | ||||||
|     pub(crate) initial_stream_window_size: u32, |     pub(crate) initial_stream_window_size: u32, | ||||||
|     pub(crate) max_frame_size: u32, |     pub(crate) max_frame_size: Option<u32>, | ||||||
|     #[cfg(feature = "runtime")] |     #[cfg(feature = "runtime")] | ||||||
|     pub(crate) keep_alive_interval: Option<Duration>, |     pub(crate) keep_alive_interval: Option<Duration>, | ||||||
|     #[cfg(feature = "runtime")] |     #[cfg(feature = "runtime")] | ||||||
| @@ -53,6 +53,10 @@ pub(crate) struct Config { | |||||||
|     pub(crate) keep_alive_while_idle: bool, |     pub(crate) keep_alive_while_idle: bool, | ||||||
|     pub(crate) max_concurrent_reset_streams: Option<usize>, |     pub(crate) max_concurrent_reset_streams: Option<usize>, | ||||||
|     pub(crate) max_send_buffer_size: usize, |     pub(crate) max_send_buffer_size: usize, | ||||||
|  |     pub(crate) max_concurrent_streams: Option<u32>, | ||||||
|  |     pub(crate) max_header_list_size: Option<u32>, | ||||||
|  |     pub(crate) enable_push: Option<bool>, | ||||||
|  |     pub(crate) header_table_size: Option<u32>, | ||||||
| } | } | ||||||
|  |  | ||||||
| impl Default for Config { | impl Default for Config { | ||||||
| @@ -61,7 +65,7 @@ impl Default for Config { | |||||||
|             adaptive_window: false, |             adaptive_window: false, | ||||||
|             initial_conn_window_size: DEFAULT_CONN_WINDOW, |             initial_conn_window_size: DEFAULT_CONN_WINDOW, | ||||||
|             initial_stream_window_size: DEFAULT_STREAM_WINDOW, |             initial_stream_window_size: DEFAULT_STREAM_WINDOW, | ||||||
|             max_frame_size: DEFAULT_MAX_FRAME_SIZE, |             max_frame_size: None, | ||||||
|             #[cfg(feature = "runtime")] |             #[cfg(feature = "runtime")] | ||||||
|             keep_alive_interval: None, |             keep_alive_interval: None, | ||||||
|             #[cfg(feature = "runtime")] |             #[cfg(feature = "runtime")] | ||||||
| @@ -70,6 +74,10 @@ impl Default for Config { | |||||||
|             keep_alive_while_idle: false, |             keep_alive_while_idle: false, | ||||||
|             max_concurrent_reset_streams: None, |             max_concurrent_reset_streams: None, | ||||||
|             max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE, |             max_send_buffer_size: DEFAULT_MAX_SEND_BUF_SIZE, | ||||||
|  |             max_concurrent_streams: None, | ||||||
|  |             max_header_list_size: None, | ||||||
|  |             enable_push: None, | ||||||
|  |             header_table_size: None, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -79,12 +87,26 @@ fn new_builder(config: &Config) -> Builder { | |||||||
|     builder |     builder | ||||||
|         .initial_window_size(config.initial_stream_window_size) |         .initial_window_size(config.initial_stream_window_size) | ||||||
|         .initial_connection_window_size(config.initial_conn_window_size) |         .initial_connection_window_size(config.initial_conn_window_size) | ||||||
|         .max_frame_size(config.max_frame_size) |         .max_send_buffer_size(config.max_send_buffer_size); | ||||||
|         .max_send_buffer_size(config.max_send_buffer_size) |  | ||||||
|         .enable_push(false); |  | ||||||
|     if let Some(max) = config.max_concurrent_reset_streams { |     if let Some(max) = config.max_concurrent_reset_streams { | ||||||
|         builder.max_concurrent_reset_streams(max); |         builder.max_concurrent_reset_streams(max); | ||||||
|     } |     } | ||||||
|  |     if let Some(max) = config.max_concurrent_streams { | ||||||
|  |         builder.max_concurrent_streams(max); | ||||||
|  |     } | ||||||
|  |     if let Some(max) = config.max_header_list_size { | ||||||
|  |         builder.max_header_list_size(max); | ||||||
|  |     } | ||||||
|  |     if let Some(opt) = config.enable_push { | ||||||
|  |         builder.enable_push(opt); | ||||||
|  |     } | ||||||
|  |     if let Some(max) = config.max_frame_size { | ||||||
|  |         builder.max_frame_size(max); | ||||||
|  |     } | ||||||
|  |     if let Some(max) = config.header_table_size { | ||||||
|  |         builder.header_table_size(max); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     builder |     builder | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user