Enable TCP nodelay by default (#860)
This commit is contained in:
@@ -137,7 +137,7 @@ impl ClientBuilder {
|
|||||||
http2_initial_stream_window_size: None,
|
http2_initial_stream_window_size: None,
|
||||||
http2_initial_connection_window_size: None,
|
http2_initial_connection_window_size: None,
|
||||||
local_address: None,
|
local_address: None,
|
||||||
nodelay: false,
|
nodelay: true,
|
||||||
trust_dns: cfg!(feature = "trust-dns"),
|
trust_dns: cfg!(feature = "trust-dns"),
|
||||||
#[cfg(feature = "cookies")]
|
#[cfg(feature = "cookies")]
|
||||||
cookie_store: None,
|
cookie_store: None,
|
||||||
@@ -630,9 +630,23 @@ impl ClientBuilder {
|
|||||||
|
|
||||||
// TCP options
|
// TCP options
|
||||||
|
|
||||||
/// Set that all sockets have `SO_NODELAY` set to `true`.
|
#[doc(hidden)]
|
||||||
pub fn tcp_nodelay(mut self) -> ClientBuilder {
|
#[deprecated(note = "tcp_nodelay is enabled by default, use `tcp_nodelay_` to disable")]
|
||||||
self.config.nodelay = true;
|
pub fn tcp_nodelay(self) -> ClientBuilder {
|
||||||
|
self.tcp_nodelay_(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set whether sockets have `SO_NODELAY` enabled.
|
||||||
|
///
|
||||||
|
/// Default is `true`.
|
||||||
|
// NOTE: Regarding naming (trailing underscore):
|
||||||
|
//
|
||||||
|
// Due to the original `tcp_nodelay()` not taking an argument, changing
|
||||||
|
// the default means a user has no way of *disabling* this feature.
|
||||||
|
//
|
||||||
|
// TODO(v0.11.x): Remove trailing underscore.
|
||||||
|
pub fn tcp_nodelay_(mut self, enabled: bool) -> ClientBuilder {
|
||||||
|
self.config.nodelay = enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,9 +327,23 @@ impl ClientBuilder {
|
|||||||
|
|
||||||
// TCP options
|
// TCP options
|
||||||
|
|
||||||
/// Set that all sockets have `SO_NODELAY` set to `true`.
|
#[doc(hidden)]
|
||||||
|
#[deprecated(note = "tcp_nodelay is enabled by default, use `tcp_nodelay_` to disable")]
|
||||||
pub fn tcp_nodelay(self) -> ClientBuilder {
|
pub fn tcp_nodelay(self) -> ClientBuilder {
|
||||||
self.with_inner(move |inner| inner.tcp_nodelay())
|
self.tcp_nodelay_(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set whether sockets have `SO_NODELAY` enabled.
|
||||||
|
///
|
||||||
|
/// Default is `true`.
|
||||||
|
// NOTE: Regarding naming (trailing underscore):
|
||||||
|
//
|
||||||
|
// Due to the original `tcp_nodelay()` not taking an argument, changing
|
||||||
|
// the default means a user has no way of *disabling* this feature.
|
||||||
|
//
|
||||||
|
// TODO(v0.11.x): Remove trailing underscore.
|
||||||
|
pub fn tcp_nodelay_(self, enabled: bool) -> ClientBuilder {
|
||||||
|
self.with_inner(move |inner| inner.tcp_nodelay_(enabled))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bind to a local IP Address.
|
/// Bind to a local IP Address.
|
||||||
|
|||||||
Reference in New Issue
Block a user