feat(server): add initial window builder methods that take self by-val (#1817)
The current `Builder` methods `http2_initial_stream_window_size` and `http2_initial_connection_window_size` take `&mut self`, while every other builder method takes `self`. That breaks up the chaining of options. This patch adds two methods that configure the same option, but take `self` instead, and have an underscore suffix (so, `http2_initial_stream_window_size_`). cc #1814
This commit is contained in:
@@ -235,14 +235,11 @@ fn spawn_hello(rt: &mut Runtime, opts: &Opts) -> SocketAddr {
|
|||||||
let addr = "127.0.0.1:0".parse().unwrap();
|
let addr = "127.0.0.1:0".parse().unwrap();
|
||||||
|
|
||||||
let body = opts.response_body;
|
let body = opts.response_body;
|
||||||
let mut builder = Server::bind(&addr)
|
let srv = Server::bind(&addr)
|
||||||
.http2_only(opts.http2);
|
.http2_only(opts.http2);
|
||||||
// api woopsie
|
.http2_initial_stream_window_size_(opts.http2_stream_window)
|
||||||
builder
|
.http2_initial_connection_window_size_(opts.http2_conn_window)
|
||||||
.http2_initial_stream_window_size(opts.http2_stream_window)
|
.serve(move || {
|
||||||
.http2_initial_connection_window_size(opts.http2_conn_window);
|
|
||||||
|
|
||||||
let srv = builder.serve(move || {
|
|
||||||
service_fn(move |req: Request<Body>| {
|
service_fn(move |req: Request<Body>| {
|
||||||
req
|
req
|
||||||
.into_body()
|
.into_body()
|
||||||
|
|||||||
@@ -302,13 +302,29 @@ impl<I, E> Builder<I, E> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// soft-deprecated? deprecation warning just seems annoying...
|
||||||
|
// reimplemented to take `self` instead of `&mut self`
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn http2_initial_stream_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
|
||||||
|
self.protocol.http2_initial_stream_window_size(sz.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
// soft-deprecated? deprecation warning just seems annoying...
|
||||||
|
// reimplemented to take `self` instead of `&mut self`
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn http2_initial_connection_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
|
||||||
|
self.protocol.http2_initial_connection_window_size(sz.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
|
/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
|
||||||
/// stream-level flow control.
|
/// stream-level flow control.
|
||||||
///
|
///
|
||||||
/// Default is 65,535
|
/// Default is 65,535
|
||||||
///
|
///
|
||||||
/// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE
|
/// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE
|
||||||
pub fn http2_initial_stream_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
|
pub fn http2_initial_stream_window_size_(mut self, sz: impl Into<Option<u32>>) -> Self {
|
||||||
self.protocol.http2_initial_stream_window_size(sz.into());
|
self.protocol.http2_initial_stream_window_size(sz.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -316,7 +332,7 @@ impl<I, E> Builder<I, E> {
|
|||||||
/// Sets the max connection-level flow control for HTTP2
|
/// Sets the max connection-level flow control for HTTP2
|
||||||
///
|
///
|
||||||
/// Default is 65,535
|
/// Default is 65,535
|
||||||
pub fn http2_initial_connection_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
|
pub fn http2_initial_connection_window_size_(mut self, sz: impl Into<Option<u32>>) -> Self {
|
||||||
self.protocol.http2_initial_connection_window_size(sz.into());
|
self.protocol.http2_initial_connection_window_size(sz.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user